2

GetWindowLong (GetTopWindow(NULL),GWL_HINSTANCE) returns 0 ... (Also tried with GetWindowLongPtr) Does anyone have an idea why is that?

Also how do you convert LONG to HINSTANCE?

  • GetTopWindow(NULL) does not return null

EDIT: The check is for a keylogger that is injected inside the application I want to log from. Using GetModuleHandle(0) I get the HINSTANCE of my injected app and if I could have the top window's HINSTANCE I could check to see if the input I get is for my application or not.

Raedok
  • 51
  • 1
  • 7
  • Please explain what you intend to use the HINSTANCE for. The top window may not belong to your process, so its instance handle is useless to you. – Raymond Chen Jan 28 '12 at 14:23
  • GetTopWindow() probably returned NULL. You'll have to have a child window for it to return a non-NULL value. Convert by casting. – Hans Passant Jan 28 '12 at 14:28
  • 2
    The HINSTANCE is not globally unique. Different processes can have the same HINSTANCE. You need to use some other method of detecting which windows you are interested in. – Raymond Chen Jan 28 '12 at 16:13

0 Answers0