CHAR szExePath[MAX_PATH];
GetModuleFileName(NULL,szExePath,MAX_PATH);
*(strrchr(szExePath,'//'))='/0';
if (GetFileAttributes(szExePath)==-1)")//判断文件是否存在
{MessageBox("!","");}
另类函数
char szFilename[_MAX_PATH];
char szDrive[_MAX_DIR];
char szDir[_MAX_DIR];
::GetModuleFileName(NULL, szFilename, sizeof(szFilename));
_tsplitpath(szFilename, szDrive, szDir, NULL, NULL);
::wsprintf(szPath, _T("%s%s"), szDrive, szDir);
文件夹路径后加上一个斜杠“//”,如果原来已经有的话就不加,没有的话加上PathAddBackslash()
关于路径的其它函数
PathAddBackslash
PathAddExtension
PathAppend
PathBuildRoot
PathCanonicalize
PathCombine
PathCompactPath
PathCompactPathEx
PathCommonPrefix
PathFileExists
PathFindExtension
PathFindFileName
PathFindNextComponent
PathFindOnPath
PathGetArgs
PathGetCharType
PathGetDriveNumber
PathIsContentType
PathIsDirectory
PathIsFileSpec
PathIsHTMLFile
PathIsPrefix
PathIsRelative
PathIsRoot
PathIsSameRoot
PathIsSystemFolder
PathIsUNC
PathIsUNCServer
PathIsUNCServerShare
PathIsURL
PathMakePretty
PathMakeSystemFolder
PathMatchSpec
PathParseIconLocation
PathQuoteSpaces
PathRelativePathTo
PathRemoveArgs
PathRemoveBackslash
PathRemoveBlanks
PathRemoveExtension
PathRemoveFileSpec
PathRenameExtension
PathSearchAndQualify
PathSetDlgItemPath
PathSkipRoot
PathStripPath
PathStripToRoot
PathUnmakeSystemFolder
PathUnquoteSpaces
一次性创建多层目录函数MakeSureDirectoryPathExists