当前位置:网站首页>Calling DLL to start thread
Calling DLL to start thread
2022-07-26 09:27:00 【asiwxy】
Wrong way to write :( Pay attention to the two lines clipped with exclamation marks ) stay ::FreeLibrary(hPro); After this line of code is executed ,dll The allocated memory space inside will be released , So I will report “ Frame not in module ”,“ Memory access error ” Or something like that .
void CMFCApplication2Dlg::OnBnClickedOk()
{
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
HINSTANCE hPro = ::LoadLibrary("MFCLibrary1.dll");// Load a self written DLL, One... Is provided
//getCFindFile Used to get a class finger
// The needle ;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (hPro == NULL)
{
return ;
}
else
{
typedef MyCFindFile* (*MENU_EXECUTE)();
MENU_EXECUTE getCFindFile = NULL;
getCFindFile = (MENU_EXECUTE)::GetProcAddress(hPro, "getCFindFile");//MenuExecute Function name
if (getCFindFile)
{
MyCFindFile * pItem = getCFindFile();
CString s;
GetDlgItemText(IDC_EDIT4,s);
s.Format(_T("%s"), s);
std::string strStr;
strStr = s.GetBuffer(0);
HWND hdlg = GetSafeHwnd();
pItem->funcFindFile(strStr, hdlg, 2);
//pItem->m_hMainDlg = GetSafeHwnd();// Pass the window handle of the current main dialog box , In this way, you can use
//m_ResultList.DeleteAllItems();// Clear the information after the last execution
//std::string strStr;
//strStr = pItem->m_PathFind.GetBuffer(0);
//funcFindFile(strStr, pItem->m_hMainDlg);
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
::FreeLibrary(hPro);
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
return;
}Correct writing :
1, take HINSTANCE hPro; Add to class member variables
2, take FreeLibrary(hPro); The function is placed in MFC Inside the exit button , Anyway, make sure you finish using hpro Don't release it before , You can also directly use static loading
边栏推荐
猜你喜欢
随机推荐
v-premission添加权限
Simple pedestrian recognition code to 88% accuracy Zheng Zhedong preparation
Source code analysis of object wait notify notifyAll
What are CSDN spaces represented by
添加dll
When you click input, the border is not displayed!
Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing
Elastic APM installation and use
Basic use of ArcGIS 1
【Mysql】Mysql锁详解(三)
The provincial government held a teleconference on safety precautions against high temperature weather across the province
nodejs服务后台执行(forever)
tabbarController的使用
Exception handling mechanism II
大二上第三周学习笔记
2022 chemical automation control instrument operation certificate test question simulation test platform operation
phpexcel导出emoji符号报错
Implementation of fragment lazy loading after multi-layer nesting
838. Heap sorting
docker配置mysql集群









