您的位置:首页 > 其它

获取应用程序目录,判断文件是否存在

2007-10-22 08:51 751 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: