调用 RegisterHotKey() 后,它似乎可以工作,因为按下时音量增大/减小没有响应,但是当我调用 UnregisterHotKey() 恢复默认值时,除非启动设备,否则音量增大/减小仍然没有响应。我怎样才能恢复它们?谢谢。
void RestoreVolumeKeys()
{
hWndTray = FindWindow(_T("HHTaskBar"), NULL);
if(hWndTray)
{
UnregisterHotKey((HWND)hWndTray, VK_TVOLUMEDOWN);
UnregisterHotKey((HWND)hWndTray, VK_TVOLUMEUP);
}
else//HHTaskBar not found then try find Tray
{
hWndTray = FindWindow(_T("Tray"), NULL);
if(hWndTray)
{
UnregisterHotKey((HWND)hWndTray, VK_TVOLUMEDOWN);
UnregisterHotKey((HWND)hWndTray, VK_TVOLUMEUP);
}
}
}
最佳答案
你没有正确使用它。第二个参数不是虚拟键,它是您在 RegisterHotKey() 调用中使用的 id
。
BOOL RegisterHotKey(HWND hWnd,
int id, // <=== this one
UINT fsModifiers,
UINT vk
);
经常检查 winapi 函数的返回值以发现此类错误。
关于c++ - UnregisterHotKey() 在 Windows Mobile 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10238666/