Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 293341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:15:46+00:00 2026-05-12T06:15:46+00:00

I am using the below code to disable the hotkeys like Alt + f4,

  • 0

I am using the below code to disable the hotkeys like Alt + f4, ctrl + c which are working perfectly. But I could not register win + L using the below code.

namespace KioskMode
{
    public partial class Test : Form
    {
        #region Dynamic Link Library Imports

        [DllImport("user32.dll")]
        private static extern int FindWindow(string cls, string wndwText);

        [DllImport("user32.dll")]
        private static extern int ShowWindow(int hwnd, int cmd);

        [DllImport("user32.dll")]
        private static extern long SHAppBarMessage(long dword, int cmd);

        [DllImport("user32.dll")]
        private static extern int RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);

        [DllImport("user32.dll")]
        private static extern int UnregisterHotKey(IntPtr hwnd, int id);

        #endregion


        #region Modifier Constants and Variables

        // Constants for modifier keys
        private const int USE_ALT = 1;
        private const int USE_CTRL = 2;
        private const int USE_SHIFT = 4;
        private const int USE_WIN = 8;

        // Hot key ID tracker
        short mHotKeyId = 0;

        #endregion

        public Test()
        {
            InitializeComponent();
            RegisterGlobalHotKey(Keys.F4, USE_ALT);
            RegisterGlobalHotKey(Keys.L, USE_WIN);
        }

        private void RegisterGlobalHotKey(Keys hotkey, int modifiers)
        {
            try
            { 
                mHotKeyId++;

                if (mHotKeyId > 0)
                {
                    // register the hot key combination
                    if (RegisterHotKey(this.Handle, mHotKeyId, modifiers, Convert.ToInt16(hotkey)) == 0)
                    {
                          MessageBox.Show("Error: " + mHotKeyId.ToString() + " - " +
                            Marshal.GetLastWin32Error().ToString(),
                            "Hot Key Registration");
                    }
                }
            }
            catch
            { 
                UnregisterGlobalHotKey();
            }
        }


        private void UnregisterGlobalHotKey()
        { 
            for (int i = 0; i < mHotKeyId; i++)
            {
                UnregisterHotKey(this.Handle, i);
            }
        }

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m); 
            const int WM_HOTKEY = 0x312;
            if (m.Msg == WM_HOTKEY)
            {
                // Ignore the request or each
                // disabled hotkey combination
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:15:47+00:00Added an answer on May 12, 2026 at 6:15 am

    You cannot register it since Windows already uses it as hotkey. If you really want to do it, you must register a low-level keyboard hook.

    Reason why you can register Alt+F4, Ctrl+C… is that those keys are not hotkeys (they are just processed in wndproc).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 149k
  • Answers 149k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You should replace double quote with This code 9&quot; x… May 12, 2026 at 9:37 am
  • Editorial Team
    Editorial Team added an answer lambdaj is a very nice library for Java 5. For… May 12, 2026 at 9:37 am
  • Editorial Team
    Editorial Team added an answer This is taken almost directly from the MoviePlayer sample project,… May 12, 2026 at 9:37 am

Related Questions

I am using a Canvas itemRenderer for a container I use to display images.
I am trying to disable a number of text boxes intended for displaying data
I'm using Logging ( import logging ) to log messages. Within 1 single module,
We are getting very slow compile times, which can take upwards of 20+ minutes
I am creating an application in .NET that will serve as a second UI

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.