以下是DLL中的注册热键代码(此DLL已注入到进程中)
BOOL CHxPlugesApp::InitInstance()
{
OnSetKey();
OnHxInit();
return CWinApp::InitInstance();
}
int CHxPlugesApp::ExitInstance()
{
OnCloseKey();
return CWinApp::ExitInstance();
}
void CHxPlugesApp::HotKeyHandle(WPARAM wParam,LPARAM lParam)
{
UINT modId;
UINT keyId;
modId = LOWORD(lParam); // 辅助键
keyId = HIWORD(lParam); // 热键
if ( keyId == VK_HOME )
{
AfxMessageBox("VK_HOME");
// ShowWindow(SW_SHOW);
// SetForegroundWindow();
}
if (keyId == VK_END)
{
AfxMessageBox("VK_END");
// ShowWindow(SW_HIDE);
}
}
// 设置热键
void CHxPlugesApp::OnSetKey()
{
m_hotEnd = GlobalAddAtom("jinduns")-0xC000;
m_hotHome = GlobalAddAtom("wenboly")-0xC000;
RegisterHotKey(NULL, m_hotHome, 0, VK_HOME);
RegisterHotKey(NULL, m_hotEnd, 0, VK_END);
}
// 注销热键
void CHxPlugesApp::OnCloseKey()
{
UnregisterHotKey(NULL, m_hotHome);
UnregisterHotKey(NULL, m_hotEnd);
DeleteAtom(m_hotHome);
DeleteAtom(m_hotEnd);
}
void OnHxInit()
{
int x;
HANDLE hThread = CreateThread(NULL, 0, ThreadProc, &x, 0, NULL);
CloseHandle(hThread);
}
//AFX_EXT_API
DWORD WINAPI ThreadProc(PVOID pParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
OnGetSkill();
MSG msg;
while (::GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
大伙帮我看看,为什么我注册后,按键无反应。。
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课