Link to home
Start Free TrialLog in
Avatar of Matlock
Matlock

asked on

DLL's GetProcAddress() cont'd to nietod

OK Thanks for your help but I'm still having problems..
GetProcAddress() is returning NULL, despite my checking
The DLL being put where it should, the DLL having the function, checking spelling etc etc etc
Could it be to do with Name Mangling ?
Or is it because of being 32 bit DLL? (app is 32 bit)
Avatar of nietod
nietod

Can you fill me in on the details?  
Never mind I found it.  (No need to point out that was yesterday)

Here is your original question for others reference.

! want to Dynamically Load a DLL in C++ Builder   Ex:
     HINSTANCE hndl;
     FARPROC Func;
     hndl = LoadLibrary("c:\\wwwroot\\cgi-bin\\control.dll");
     Func = (FARPROC) GetProcAddress(hndl,"Passed");
     if(Func(Name.c_str(),Password.c_str())){ FreeLibrary(hndl); return 1;}//Passed
     else {FreeLibrary(hndl); return 0;}

    I'm getting an error message saying "Too Many Arguments" to the DLL function even though the number
    of arguments is correct
    Regards Matlock.

Yes, the problem is very likely to be name mangeling.
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Matlock

ASKER

I guess I must be clucthing at straws afraid I have already declared it as
extern "C" __declspec(dllexport) bool Passed(char *,char *);
and even tried
extern "C" __declspec(dllexport) bool PASSED(char *,char *);
and tried to fine PASSED insted , all to no avail

Matlock
Opps.  I forgot something.  Builder prefixes the name with an underscore.  Look for "_Passed".  (MSVC does not do that by the way.)  

Now something from the its better to teach a man to cook than to feed him a meal department.

There are a variety of tools available for listing the exported or imported procedures in an EXE or DLL.  I use DUMPBIN.EXE which came with MSVC (Also part of MSDN? or SDK?)  Borland probably has a similar tool if you don't have it.  Use it to list the exports in the DLL. (That's how I found out about the underscore.)
Avatar of Matlock

ASKER

Thankyou It now works brilliantly!
Yes it was the underscore.
OK I appreciate the advice on looking at the contents first
Haven't got the tools yet but looking through notepad I found
that the DLL had been created without the function, re-compiled and there it was. Don't know why, not worried.
Thanks for all your Help
Matlock