Results 1 to 2 of 2

Thread: Passing to a dll

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222

    Passing to a dll

    Hello Again

    I got a simple function working from a dll, but now i can't seem to pass it variables to act on!

    Inside my dll i have the function:

    int WINAPI InitHooksDll(HWND hwndMainWindow, int nWinLineHeight)
    {
    hwndMain = hwndMainWindow;
    nLineHeight = nWinLineHeight;

    InitCalled = 1;
    return (0);
    }

    and I can call the function "test" which has no varibales apssed to it ok, and it is called as follows:

    HMODULE hkeyDLL = LoadLibrary("keydll");
    if(!hkeyDLL) {
    MessageBox(NULL, "Could not load hkeyDLL library", "Error", MB_OK);
    return -1;
    }

    if (hkeyDLL != NULL)
    {
    ProcAdd = (MYPROC) GetProcAddress(hkeyDLL, "Test");

    // If the function address is valid, call the function.

    if (fRunTimeLinkSuccess = (ProcAdd != NULL))
    (ProcAdd) ("message via DLL function\n");

    // Free the DLL module.

    fFreeResult = FreeLibrary(hkeyDLL);
    }

    How do I alter this code to run the function above (InitHooksDll) and pass it the required variables?!

    I don't know whether I have explained myself to well, so if anybody understand could you please shed some light! or If not let me know and I'll try and re-explain myself!

    Cheers in advance

    Andy

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    the type of ProcAdd should be defined like this:
    Code:
    typedef int (WINAPI *PROCPTR)(HWND, int);
    Then it should work.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width