獲取程序的所在目錄

//獲取ini配置文件完全名稱

CHAR    FilePath[255];
void CTenergyurlAccess::GetFilePath()
{  
 memset(FilePath, 0, sizeof(FilePath));
 CHAR sFilePath[MAX_PATH];
 GetModuleFileName( NULL, sFilePath, MAX_PATH );
 char * p=strrchr(sFilePath, '\\');
 if (p)
 {
  *(p+1)=0;
  strcat(sFilePath, "driver\\EnergyUrl.ini");
 }
 
 memcpy(FilePath,sFilePath,strlen(sFilePath));
 //Trace2Logger("ini配置文件:%s", FilePath);
}

 

LPCSTR GetModuleDir()//返回路徑有後斜槓
{
 static char dir[_MAX_FNAME]={0};
 if (dir[0])
  return dir;
 
 GetModuleFileName(NULL, dir, sizeof(dir));
 char* pEnd = strrchr(dir, '\\');
 if (pEnd) pEnd[1] = 0;
 return dir;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章