How can to discover if has a recorded RegisterHotKey in Windows?

How can to my application Delphi discover if has RegisterHotKey recorded for another program?
Who is Participating?
jimyXConnect With a Mentor Commented:
You can check the returned value of the function RegisterHotKey:

id2 := GlobalAddAtom('Hotkey2');
  if RegisterHotKey(Handle, id2, MOD_CONTROL + MOD_Alt ,VK_Delete) then
    showmessage('Error, Alt+Ctrl+ Del is already in use. Not registered');

Open in new window

mccoymadAuthor Commented:
No, no
You did not understand my problem!
I want to know I eat to detect if some hotkey was registered, any one! Not one hotkey specific!
jimyXConnect With a Mentor Commented:
After deep search, it seems that you can not do that with just delphi code and you need to have a way to access the OS where the hotkeys are stored.

But you have an option of designing a testing application that attempts to loop through the different combination of the possible keys such as (Ctrl+Alt+A) and try to set it if not succeeded (used by another application) then release that and try the second combination (Ctrl+Alt+B) and so on until you scan all the common combinations:

Here is an example for testing Alt+Ctrl combination with A to Z:

procedure TForm1.Button1Click(Sender: TObject);
  i, j : integer;
  for i := $41 to $41+25 do
      j := GlobalAddAtom('H');
      if not RegisterHotKey(Handle, j, MOD_ALT + MOD_CONTROL, i) then
          showmessage('Alt + Ctrl + '+ char(i) +' Not available');
          showmessage('Alt + Ctrl + '+ char(i) +' Available');
          UnRegisterHotKey(Handle, j);

Open in new window

You can get all the Virtual keys from

Here is an interesting topic discussing the same issue:

In this link there is a similar question as yours:

// Modifiers
Win button = MOD_WIN

//virtual key codes of the alphabet because it is not clear in the above link from
A = $41;
B = $42;
C = $43;
D = $44;
E = $45;
F = $46;
G = $47;
H = $48;
I = $49;
J = $4A;
K = $4B;
L = $4C;
M = $4D;
N = $4E;
O = $4F;
P = $50;
Q = $51;
R = $52;
S = $53;
T = $54;
U = $55;
V = $56;
W = $57;
X = $58;
Y = $59;
Z = $5A;

Delete button = $2E; // or use VK_Delete directly

Open in new window

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

lomo74Connect With a Mentor Commented:
I'm afraid jimyX is right --
the only chance you have is to check every combination of hotkey for availability --
there are 4 modifiers plus 26 letters (if you limit your search to alphabet...), total loops are 2^4*26=416 :-(
here is a more complete piece of code --

program Project1;


  SysUtils, Windows;

  a, c, s, w, m, h, id: Integer;
  desc: string;

  ALT: array[0..1] of string = (
    'Alt + '
  CTRL: array[0..1] of string = (
    'Ctrl + '
  SHIFT: array[0..1] of string = (
    'Shift + '
  WIN: array[0..1] of string = (
    'Win + '

    id := GlobalAddAtom('HotKey');
    for a := 0 to 1 do
      for c := 0 to 1 do
        for s := 0 to 1 do
          for w := 0 to 1 do begin
            m := a * MOD_ALT +
                 c * MOD_CONTROL +
                 s * MOD_SHIFT +
                 w * MOD_WIN;
            desc := ALT[a] + CTRL[c] + SHIFT[s] + WIN[w];
            for h := $41 to $5A do begin
              if RegisterHotKey(0, id, m, h) then begin
                Writeln(desc + Char(h) + ' available');
                UnregisterHotKey(0, id);
              end else if GetLastError = ERROR_HOTKEY_ALREADY_REGISTERED then
                Writeln(desc + Char(h) + ' unavailable')
                Writeln('An error occurred!')
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);

Open in new window

mccoymadAuthor Commented:
I already had made a Loop that tests all the possibilities of hotkey, but I wanted to make a cleaner routine!
It found that the Windows had a ready command!
I've been looking around but apparently there is no such clean code.

What is that command that you found ?
mccoymadAuthor Commented:
All program that captures the screen goes to call the function windows GetWindowDC (GetDesktopWindow), then the part of the code .exe will be equal for all, agrees to me?

I made two programs in Delphi.

The first one uses the function GetWindowDC (GetDesktopWindow) and second hand it does not use the function.

I compared the code .exe of the two programs and more found the following code in the first program:

232, 218, 151, 251,
255, 80, 232, 188,
152, 251, 255, 163,
212, 251, 68, 0

Now I have that to look for inside of other programs that capture the screen, if they possess a part of this code.

It will be that I am certain?
I feel you are a bit confused.
You want to know which hotkeys are reserved by other applications, right?
Thus... what have GetWindowDC and other GDI functions got to do with your requirements?
And, besides that, what are those numbers?
Tell me you're not trying to interpret CPU instructions that way
mccoymadAuthor Commented:
I not bit confused!

1º I need to discover if some program in use in the WIndows can copy or this copying the screen of windows
2º I check that the majority of them uses hotkeys, not all, then is not enough to block hotkeys, necessary discovered one another solution

3º Then I verified that to copy the screen ALL the programs need to use the GetWindowDC function

4º Therefore I am looking the instructions of the corresponding processor to the GetWindowDC command

5º If I to discover, resolve my problem because when verifying an open program I check if it uses the instructions of the corresponding processor to the GetWindowDC command

You understood
I understand that you posted this question:
"How can to discover if has a recorded RegisterHotKey in Windows?"
and now you're pushing 4 more problems that have nothing to do with your question.
So please don't go off topic. Not on EE, if you want to receive help.

Did my and jimyX's posts help you?

You said "It found that the Windows had a ready command!".
Please tell us which is this fabulous command. Remember: we're talking about HOTKEYS not windows' DC or the like.
mccoymadAuthor Commented:
I finish this topic and I have new topic more especific!
the author has received two valid answers for his question, which is quite clear indeed.
the fact that, later on, he got confused about his whole project is not a valid reason for deleting this question without assigning points to Experts who took the time to help him.
All Courses

From novice to tech pro — start learning today.