开发者

How to check for fail to register a hotkey?

how make my app t开发者_如何学编程o check if it fail to register a hotkey? which I have registered it using "RegisterHotKey" function).

I just need to know the checking method.

thanks


I am assuming you are using P/Invoke to call RegisterHotKey. If so your declaration should look like the following.

  <DllImport("user32.dll", SetLastError:=True)> _
  Private Shared Function RegisterHotKey(ByVal hWnd As IntPtr, ByVal id As Int32, ByVal fsModifier As UInt32, ByVal vk As UInt32) As <MarshalAs(UnmanagedType.Bool)> Boolean
  End Function

With this you can check the return value of RegisterHotKey and if it is false, you can use Marshal.GetLastError to get the Win32 error code which provides more info as to why the call failed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜