我使用以下代码使用c#注册热键.但有时我会抛出"无法注册热键"的异常.这个错误的原因是什么?而且不一致.我怎么处理这个?
public void RegisterHotKey(ModifierKeys modifier, Keys key)
{
// increment the counter.
_currentId = _currentId + 1;
// register the hot key.
if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
throw new InvalidOperationException("Couldn’t register the hot key.");
}
Run Code Online (Sandbox Code Playgroud)