Thread: global dll file

  1. #1
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125

    global dll file

    Hi all;

    i am trying to write a dll file and then use the functions inside it in a exe file. However i am having trouble when i try and include the functions inside the dll file in my exe program. I was wondering if there is a good tutorial/book around that goes into this in detail without the useage of MFC. The dll file has to be global because i am using hooks inside it.

    thanks heaps.

  2. #2
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125
    Okay to add to my question...

    in my dll file i have

    LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
    log the keys...
    ...
    return nexthookproc();
    }

    then in my exe i use

    HOOKPROC hookproc;
    HINSTANCE dllfile;
    HHOOK hhook;

    dllfile = LoadLibrary((LPCTSTR) "c:\\PcDll.dll");
    hhook = (HOOKPROC)GetProcAddress(dllfile, "HookProc");
    hhook = SetWindowsHookEx(WH_KEYBOARD,
    hookproc, dllfile, 0);

    to load the dll and set the hookproc, however it doesnt seem to work. How do i call HookProc() found inside my dll in my exe?

  3. #3
    zoo
    Guest
    Try this. Change this:

    hhook = (HOOKPROC)GetProcAddress(dllfile, "HookProc");

    to this:

    hookproc = (HOOKPROC)GetProcAddress(dllfile, "HookProc");

  4. #4
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Lightbulb 2 More Things!

    You:

    A: Forgot __declspec(dllexport) in the dll
    B: Forgot that C++ dlls export with argument info:

    ?HookProc@@blahblahblah
    Use dependancy walker to figure out this name.

    SPH

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Replies: 4
    Last Post: 07-06-2006, 02:53 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM