RegisterGlobalHotKey() public static method

public static RegisterGlobalHotKey ( int hotkeyValue, int modifiers, Form targetForm ) : int
hotkeyValue int
modifiers int
targetForm System.Windows.Forms.Form
return int
        public bool RegisterOriginalHotkey(Keys hotkey, int hotkeyValue, ModKeys modifiers)
        {
            var modKey = Keys.None;

            if ((modifiers & ModKeys.Alt) == ModKeys.Alt)
            {
                modKey |= Keys.Alt;
            }
            if ((modifiers & ModKeys.Ctrl) == ModKeys.Ctrl)
            {
                modKey |= Keys.Control;
            }
            if ((modifiers & ModKeys.Shift) == ModKeys.Shift)
            {
                modKey |= Keys.Shift;
            }
            if ((modifiers & ModKeys.Win) == ModKeys.Win)
            {
                modKey |= Keys.LWin;
            }
            var key = new KeyEventArgs(hotkey | modKey);

            foreach (var kvp in this._hotkeyID)
            {
                if (kvp.Value.KeyEvent.KeyData == key.KeyData && kvp.Value.Value == hotkeyValue)
                {
                    return(true);                                                                             // 登録済みなら正常終了
                }
            }
            var hotkeyId = Win32Api.RegisterGlobalHotKey(hotkeyValue, (int)modifiers, this._targetForm);

            if (hotkeyId > 0)
            {
                this._hotkeyID.Add(hotkeyId, new KeyEventValue(key, hotkeyValue));
                return(true);
            }
            return(false);
        }