UnregisterHotKey() 在 Windows Mobile 上不起作用

UnregisterHotKey() does not work on Windows Mobile

本文关键字:Mobile 不起作用 Windows UnregisterHotKey      更新时间:2023-10-16
调用 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 函数的返回值以查找此类错误。