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());
}
}