i want to call some functions from a DLL(which is provided by a hardware manufacturer without the .lib and .def). I've used these following code

    HINSTANCE hinstLib; 
    MYPROC ProcAdd=NULL; 
    BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; 

    // Get a handle to the DLL module.

    hinstLib = LoadLibrary(TEXT("C:\My.dll")); 

    // If the handle is valid, try to get the function address.

    if (hinstLib != NULL) 

 ProcAdd = (MYPROC) GetProcAddress(hinstLib, "funcinDLL");

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

        if (NULL != ProcAdd) 
            fRunTimeLinkSuccess = TRUE;
            (*ProcAdd) (); 
        // Free the DLL module.

        fFreeResult = FreeLibrary(hinstLib); 

    // If unable to call the DLL function, use an alternative.
    if (! fRunTimeLinkSuccess) 
        printf("Message printed from executable\n"); 

but LoadLybrary is failing to load the DLL..
can anyone suggest me , how can i do the job?

Edited by mike_2000_17: Fixed formatting

8 Years
Discussion Span
Last Post by Banfa

When LoadLibrary fails it must be for a reason. Assuming that you have the path correct I suggest you call and print the return value from GetLastError to get some clarificaion of what is causing the problem.

You can look up the value returned from GetLastError in winerror.h

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.