当我运行RegisterHotKey
时,它返回false。可能的原因是什么?
internal void RegisterHotKey2(ModifierKeys modifier, Keys key)
{
_cID += 1;
if (!RegisterHotKey(_window.Handle, _cID, (uint)modifier, (uint)key))
{
Console.WriteLine("oh no: " + modifier.ToString() + " + " + key.ToString());
throw new InvalidOperationException("couldn't register noooooo");
}
}
OLD VERSION(请勿判断)
internal void RegisterHotKey2(ModifierKeys modifier, Keys key)
{
_cID += 1;
if (!RegisterHotKey(_window.Handle, _cID, (uint)modifier, (uint)key))
Console.WriteLine("oh no: " + modifier.ToString() + " + " + key.ToString());
throw new InvalidOperationException("couldn't register noooooo");
}
答案 0 :(得分:1)
似乎您的代码将始终抛出异常,请尝试更改为以下..
internal void RegisterHotKey2(ModifierKeys modifier, Keys key)
{
_cID += 1;
if (!RegisterHotKey(_window.Handle, _cID, (uint)modifier, (uint)key))
{
Console.WriteLine("oh no: " + modifier.ToString() + " + " + key.ToString());
throw new InvalidOperationException("couldn't register noooooo");
}
}