Hello @Mai Co Zo Xop ,
I can reproduce this issue using code sample based your demonstrated video. Root cause is missing CALLBACK
calling convention for the hook procedure definition in the DLL. Refer to "CBTProc callback function".
After add CALLBACK
calling convention, GetProcAddress(dll, "TestProc");
will fail to find the TestProc
function. To solve this problem you can edit the TestProc
function like this:
#define EXPORT comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__)
extern "C" _declspec(dllexport) LRESULT CALLBACK TestProc(int nCode, WPARAM wParam, LPARAM lParam)
{
#pragma EXPORT
return nCode < 0 ? CallNextHookEx(0, nCode, wParam, lParam) : 0;
}
Another method is "Exporting from a DLL Using DEF Files".
Thank you!
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.