Getting the name of program/thread that called keyboard hook.

How do I go about finding out which program called my keyboard hook procedure?  What if there are no applications running, how does the OS (W98) identify itself?
TraalAsked:
Who is Participating?
 
robert_marquardtConnect With a Mentor Commented:
The hook DLL is docked to the program. The DLL is now part of this program. Use the standard Win32 function to get the exe name in the DLL. That works for me and a shell hook. There is always a program running. at least the system itself. Sometimes you will get a DLL name especially for an explorer window.
0
 
MadshiCommented:
Call GetModuleFileName(GetModuleHandle(0), ...).

Regards, Madshi.
0
 
robert_marquardtCommented:
GetModuleFileName(GetWindowLong(HWND(wPar),GWL_HINSTANCE),buf,256);

All hooks hand in a window handle.
0
 
MadshiCommented:
I prefer my suggestion, simply because you don't need a window handle for it. In keyboard hook dlls you often don't have a window handle.
0
 
hhamsterProgramerCommented:
following
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.