//--1--获取可执行文件的路径,即exe调用dll时,无论在哪个dll中使用如下代码,得到的都是exe路径
CString GetExePath(void)
{
CString strModuleFile;
GetModuleFileName(NULL,strModuleFile.GetBuffer(1024),1024);
strModuleFile.ReleaseBuffer();
CString strExePath = strModuleFile.Left(strModuleFile.ReverseFind('\\'));
return strExePath;
}
//--2-- 获取当前路径,即exe调用dll时,在哪个dll使用如下代码,得到的就是哪个dll的路径
TCHAR szDir[MAX_PATH];
HMODULE hModule = reinterpret_cast<HMODULE>(&__ImageBase);
GetModuleFileName(hModule, szDir, MAX_PATH);
PathRemoveFileSpec(szDir);
判断路径是否存在
BOOL isexist=PathFileExists( Path_in );//判断路径是否存在