char pBuf[MAX_PATH]; GetCurrentDirectory(MAX_PATH,pBuf);
CFileDialog hFileDlg(false,NULL ,
NULL,
OFN_FILEMUSTEXIST | OFN_READONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
TEXT("Text Files (*.txt)|*.txt|All Files(*.*)|*.*|"),
NULL);
CString strCurPath;
GetModuleFileName(NULL,strCurPath.GetBuffer(MAX_PATH),MAX_PATH);
int pos= strCurPath.ReverseFind(_T('\\'));
strCurPath = strCurPath.Left(pos);
CFileDialog hFileDlg(false,NULL ,
NULL,
OFN_FILEMUSTEXIST | OFN_READONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
TEXT("Text Files (*.txt)|*.txt|All Files(*.*)|*.*|"),
NULL);
if(hFileDlg.DoModal() == IDOK) {
m_strEdtSrcFile = hFileDlg.GetPathName();
UpdateData(FALSE);
}
/*
#include "shlwapi.h"
#pragma comment(lib, "shlwapi.lib ")
*/
TCHAR szPath2[] = TEXT("D:\\Test\\tst.exe");
PathStripPath(szPath2);
// Result: szPath2 ==tst.exe
TCHAR szPath3[] = TEXT("D:\\Test\\Debug");
PathStripPath(szPath3);
// Result: szPath3 == Debug
TCHAR szPath4[] = TEXT("D:\\Test\\Debug\\");
PathStripPath(szPath4);
// Result: szPath4 == Debug\
TCHAR szPath5[] = TEXT("D:\\");
PathStripPath(szPath5);
// Result: szPath5 == D:\
CString strCurPath;
GetModuleFileName(NULL,strCurPath.GetBuffer(MAX_PATH),MAX_PATH)
strCurPath.ReleaseBuffer();//Must ReleaseBuffer, or GetLength=0
int pos= strCurPath.ReverseFind(_T('\\'));
int len = strCurPath.GetLength();
strCurPath = strCurPath.Right(len-pos-1);
#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{
//先获取运行程序的完整路径
char szFileName[256];
memset(szFileName,'"0',sizeof(szFileName));
GetModuleFileName(NULL,szFileName, sizeof(szFileName));
//再分割完整路径的字符串,最后一个就是程序的名字
char seps[] = "\\" ;
char *token = NULL;
char exeName[256];
memset(exeName,'\0',sizeof(exeName));
token = strtok( szFileName, seps );
while( token != NULL )
{
sprintf(exeName,"%s",token);
token = strtok( NULL, seps );
}
printf("%s\n",exeName);
getchar();
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有