|
|
|
[求助]LoadLibrary失败
使用下面的LoadLibraryEx可以成功 HMODULE hmod = LoadLibraryEx("C:\\MyDll.dll", NULL, DONT_RESOLVE_DLL_REFERENCES ) 看了下MSDN: DONT_RESOLVE_DLL_REFERENCES If this value is used, and the executable module is a DLL, the system does not call DllMain for process and thread initialization and termination. Also, the system does not load additional executable modules that are referenced by the specified module. If this value is not used, and the executable module is a DLL, the system calls DllMain for process and thread initialization and termination. The system loads additional executable modules that are referenced by the specified module. 也就是说不会执行dll入口函数,LoadLibrary会在哪个环节出错呢? 边思考边等高手... |
|
如何有效的调试MFC DLL
我试了下,VC6版本.Build->Start to debug->Attach to process,选择目标进程后,vc已经附加到目标进程,感觉和OD一样,无法调试时显示源码:( 试过被调试的dll选用debug版本还是一样,请问你是怎么让他调试时显示源码的呢? |
|
如何有效的调试MFC DLL
这个不管用,因为暴异常的地方是在MFC源码里头,而不是我的MFC dll代码里头(dll的代码哪里出问题,这个我可以确定,因为有自己的SEH跟着) |
|
new一个MFC窗口类,delete时报异常
窗口已经出来了 经过调试测试,找到问题出错地方及原因: 上面OD代码就是下面的MFC源码: BOOL CWnd::DestroyWindow() { if (m_hWnd == NULL) return FALSE; CHandleMap* pMap = afxMapHWND(); //错误就是这里找不到handle ASSERT(pMap != NULL); CWnd* pWnd = (CWnd*)pMap->LookupPermanent(m_hWnd); #ifdef _DEBUG HWND hWndOrig = m_hWnd; #endif #ifdef _AFX_NO_OCC_SUPPORT BOOL bResult = ::DestroyWindow(m_hWnd); #else //_AFX_NO_OCC_SUPPORT BOOL bResult; if (m_pCtrlSite == NULL) bResult = ::DestroyWindow(m_hWnd); else bResult = m_pCtrlSite->DestroyControl(); #endif //_AFX_NO_OCC_SUPPORT ... CHandleMap* PASCAL afxMapHWND(BOOL bCreate) { AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState(); //看这个名字,好像是跟线程有关的 if (pState->m_pmapHWND == NULL && bCreate) { BOOL bEnable = AfxEnableMemoryTracking(FALSE); #ifndef _AFX_PORTABLE _PNH pnhOldHandler = AfxSetNewHandler(&AfxCriticalNewHandler); #endif pState->m_pmapHWND = new CHandleMap(RUNTIME_CLASS(CTempWnd), offsetof(CWnd, m_hWnd)); #ifndef _AFX_PORTABLE AfxSetNewHandler(pnhOldHandler); #endif AfxEnableMemoryTracking(bEnable); } return pState->m_pmapHWND; } 我之前的new和delete的代码不是在一个线程的,改成一个线程上操作时就不会报错. 请问高人,能不能在不同线程new/delete一个mfc窗口??? |
|
|
|
临界区CriticalSection/互斥Mutex释放问题
在这个类构造函数执行时,由于代码简单,应该没那么容易造成线程奔溃,也就不会出现没构造就被析构的情况. 我之前的评论是我对类出作用域被自动析构没理解好,我以为在try{}块里面完成析构的 谢谢提醒.另外你知道mutex在这种情况下如何去正确释放吗? |
|
临界区CriticalSection/互斥Mutex释放问题
如果是使用互斥Mutex,该如何解决这个异常释放问题? |
|
临界区CriticalSection/互斥Mutex释放问题
类封装看过去没问题,但实质上跟普通代码一样,线程异常时还是有可能正好处于临界区内运行 |
|
临界区CriticalSection/互斥Mutex释放问题
这个无法判断是哪个线程占用了临界区,也就不好对临界区进行删除或初始化操作.若其它线程占用,若使用初始化,当其它线程释放时,会对临界区的一些计数产生影响. |
|
临界区CriticalSection/互斥Mutex释放问题
这个应该可以 :) |
|
临界区CriticalSection/互斥Mutex释放问题
DWORD dwTid = GetCurrentThreadId(); if (dwTid == (DWORD)cs_stask_state.OwningThread) //当前线程占用 { //DeleteCriticalSection(&cs_stask_state); InitializeCriticalSection(&cs_stask_state); //经测试,直接调用初始化就行 } 自己想了这么个方法,判断若是当前异常线程占用,就直接再次初始化,因为还需要再次使用该临界区 看这种写法是否符合常规? |
|
Windows消息钩子回调函数是在哪个线程执行的?
我看了下MSDN,像键盘钩子是被勾的线程中执行的. 而WH_CALLWNDPROC钩子是在勾方线程中执行的. The WH_CALLWNDPROC hook is called in the context of the thread that calls SendMessage, not the thread that receives the message thank you all the same:) |
|
关于PostMessage和SendMessage函数的消息阻塞
估计那个窗口在未获取输入焦点前不接收消息,试下下面的代码: //如果不需要前置,则先注释掉测试下面的 ::SetWindowPos(hwnd_for_recv, HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); ::SetWindowPos(hwnd_for_recv, HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); ::SetForegroundWindow(hwnd_for_recv); /* 用附加本线程到最前面窗口的线程,从而欺骗windows。 这个可以 */ DWORD pid = GetWindowThreadProcessId(::GetForegroundWindow(), NULL); AttachThreadInput(pid, dwThreadId_for_recv, TRUE); ::SetForegroundWindow(hwnd_for_recv); ::SetFocus(hwnd_for_recv); ::PostMessage(hwnd_for_recv,...); AttachThreadInput(pid, dwThreadId_for_recv, FALSE); |
|
|
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值