怡宁塑胶模具设计

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

string GetPath();//输出程序路径
string YiNingToolPath(string DLLDir); //分割程序路径获取工具目录


HMODULE GetSelfModuleHandle() //获取运行程序的路径
{

MEMORY_BASIC_INFORMATION mbi;
return ((::VirtualQuery(GetSelfModuleHandle, &mbi, sizeof(mbi)) != 0)
? (HMODULE)mbi.AllocationBase : NULL);
}
CString GetProgramDir() //获取运行程序的路径
{
char exeFullPath[MAX_PATH]; // 全路径
string strPath = "";
GetModuleFileName(GetSelfModuleHandle(), exeFullPath, MAX_PATH);
strPath = (string)exeFullPath; // 获取程序路径
int pos = strPath.find_last_of('\\', strPath.length());
CString path;
path = strPath.substr(0, pos).c_str();
return path;
}

string YN_BOM::GetPath() //输出程序路径
{
CString exe_path = GetProgramDir();
string ProgramDirPath = exe_path;

return string(ProgramDirPath);//返回路径
}

string YN_BOM::YiNingToolPath(string DLLDir) //分割程序路径获取工具目录
{
try
{
//反向找位置,分割字符串(只读取文件夹路径)
string strPath = DLLDir;
string strDir;
int nPos = strPath.find_last_of('\\');
if (string::npos != nPos)
{
strDir = strPath.substr(0, nPos - 11);
}

return string(strDir);//返回文件夹路径
}
catch (exception& ex)
{
//---- Enter your exception handling code here -----
YN_BOM::theUI->NXMessageBox()->Show("分割程序路径获取工具目录", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}


}

posted on 2021-07-10 15:20  怡宁塑胶模具设计  阅读(227)  评论(0编辑  收藏  举报