GetModuleFileName獲取當前程序已載入模組的檔案的完整路徑
阿新 • • 發佈:2019-02-19
DWORD CMonPrtAndSScard::_LoadUploadModule()
{
DWORD dwRet = 0;
wchar_t wszAppPath[MAX_PATH] = {NULL};
GetModuleFileName(NULL, wszAppPath, MAX_PATH);
wstring wsTemp(wszAppPath);
wstring wsUploadpath;
wsUploadpath = wsTemp.substr(0, wsTemp.find_last_of(L"\\")+1);
wsUploadpath.append(L"LibUpload.dll");
m_uploadMoudle = LoadLibrary(wsUploadpath.c_str());
if (NULL == m_uploadMoudle)
{
m_uploadMoudle = NULL;
dwRet = GetLastError();
g_PluginPrtAndSSCardMon.Error(L"Error occured in fun:%s,line:%d,error code:%d", __FUNCTIONW__, __LINE__, dwRet);
goto END;
}
m_uploadRecord = (POSTSOAPRECORD)GetProcAddress(m_uploadMoudle, "PostSOAPRecord");
if(NULL == m_uploadRecord)
{
dwRet = GetLastError();
g_PluginPrtAndSSCardMon.Error(L"Error occured in fun:%s,line:%d,error code:%d", __FUNCTIONW__, __LINE__, dwRet);
goto END;
}
END:
return dwRet;
}
{
DWORD dwRet = 0;
wchar_t wszAppPath[MAX_PATH] = {NULL};
GetModuleFileName(NULL, wszAppPath, MAX_PATH);
wstring wsTemp(wszAppPath);
wstring wsUploadpath;
wsUploadpath = wsTemp.substr(0, wsTemp.find_last_of(L"\\")+1);
wsUploadpath.append(L"LibUpload.dll");
m_uploadMoudle = LoadLibrary(wsUploadpath.c_str());
if (NULL == m_uploadMoudle)
{
m_uploadMoudle = NULL;
dwRet = GetLastError();
g_PluginPrtAndSSCardMon.Error(L"Error occured in fun:%s,line:%d,error code:%d", __FUNCTIONW__, __LINE__, dwRet);
goto END;
}
m_uploadRecord = (POSTSOAPRECORD)GetProcAddress(m_uploadMoudle, "PostSOAPRecord");
if(NULL == m_uploadRecord)
{
dwRet = GetLastError();
g_PluginPrtAndSSCardMon.Error(L"Error occured in fun:%s,line:%d,error code:%d", __FUNCTIONW__, __LINE__, dwRet);
goto END;
}
END:
return dwRet;
}