hi
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) 
    { 
        std::cout<<"loaded\n";



 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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.