2009-08-15 62 views

回答

2

使用GetModuleFilename()來獲取應用程序的完整路徑,並砍掉可執行文件的名稱:

wchar_t appPath[ MAX_PATH ]; 
    memset(appPath, 0, MAX_PATH * sizeof(wchar_t)); 

    wchar_t modulePath[MAX_PATH]; 
    if (GetModuleFileName(NULL, modulePath, MAX_PATH) > 0) 
    { 
     wchar_t *lastBackSlash = wcsrchr(modulePath, '\\'); 
     if (lastBackSlash) 
     { 
      memcpy(appPath, modulePath, (lastBackSlash - modulePath) * sizeof(wchar_t)); 
     } 
    } 
相關問題