您好,登錄后才能下訂單哦!
獲取工程運(yùn)行路徑源代碼
string GetProgramDir()
{
char exeFullPath[MAX_PATH]; // Full path
string strPath = "";
GetModuleFileName(NULL,exeFullPath,MAX_PATH);
strPath=(string)exeFullPath; // Get full path of the file
int pos = strPath.find_last_of('\\', strPath.length());
return strPath.substr(0, pos); // Return the directory without the file name
}
執(zhí)行結(jié)果:
ocx:會(huì)是IE路徑安裝路徑
EXE:exe所在文件夾
獲取工程當(dāng)前路徑源代碼
string GetCurrentDir(const string &path){
string ls_FileName;
LPTSTR lpBuffer;
UINT uSize;
HANDLE hHeap;
uSize=(GetCurrentDirectory(0,NULL))*sizeof(TCHAR);
hHeap=GetProcessHeap();
lpBuffer=(LPSTR)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,uSize);
GetCurrentDirectory(uSize,lpBuffer);
ls_FileName = (string) lpBuffer;
ls_FileName.append(path);
return ls_FileName;
}
執(zhí)行結(jié)果:
ocx:會(huì)是用戶桌面
EXE:運(yùn)行該exe工程的文件夾路徑
debug:(工程名AAA)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。