获得程序所在路径

来源:互联网 发布:易语言管理系统源码 编辑:程序博客网 时间:2024/06/10 08:46

 if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
 {
  // TODO: change error code to suit your needs
  _tprintf(_T("Fatal Error: MFC initialization failed/n"));
 }//解决Win32调用程序GetModuleFileName会在Degug崩溃的错误;加上就不会debug时候AfxGetInstanceHandle()有那个debug Assert Failed错误


 char path[_MAX_PATH];
 GetModuleFileName(NULL,path,_MAX_PATH);
 string strFile;
 strFile = path;//C:/folderl/wein32.exe
 
 int k = strFile.rfind('//');
 string strpath = strFile.substr(0,k); ;//C:/folderl

原创粉丝点击