Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SetWindowsHookEx and HINSTANCE;

SetWindowsHookEx and HINSTANCE;

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bo Hunter
    wrote on last edited by
    #1

    I am tring to build a keyboard hook that blocks the windows keys. It has to be in a seperate dll. The call to SetWindowsHookEx requires a HINSTANCE to the dll. How do I get an HINSTANCE to my dll with out having to use CWinApp. There is way more stuff in the CWinApp class than I would like to use.

    //This works
    class CTaskKeyHookDll : public CWinApp
    {
    public :
    	CTaskKeyHookDll(){ }
    	~CTaskKeyHookDll(){ }
    } MyDll;
    
    
    
    //This don't work
    class CTaskKeyHookDll
    {
    public :
    	HINSTANCE hInstance;
    
    	CTaskKeyHookDll(){ }
    	~CTaskKeyHookDll(){ }
    } MyDll;
    

    Anyone know how to do this? Thank You Bo Hunter

    A 1 Reply Last reply
    0
    • B Bo Hunter

      I am tring to build a keyboard hook that blocks the windows keys. It has to be in a seperate dll. The call to SetWindowsHookEx requires a HINSTANCE to the dll. How do I get an HINSTANCE to my dll with out having to use CWinApp. There is way more stuff in the CWinApp class than I would like to use.

      //This works
      class CTaskKeyHookDll : public CWinApp
      {
      public :
      	CTaskKeyHookDll(){ }
      	~CTaskKeyHookDll(){ }
      } MyDll;
      
      
      
      //This don't work
      class CTaskKeyHookDll
      {
      public :
      	HINSTANCE hInstance;
      
      	CTaskKeyHookDll(){ }
      	~CTaskKeyHookDll(){ }
      } MyDll;
      

      Anyone know how to do this? Thank You Bo Hunter

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      in your overridden DllMain() save the first parameter(HINSTANCE) to g_hInstance.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups