Solved

DLL's GetProcAddress() cont'd to nietod

Posted on 1998-04-22
6
224 Views
Last Modified: 2010-04-10
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)
0
Comment
Question by:Matlock
  • 4
  • 2
6 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1163099
Can you fill me in on the details?  
0
 
LVL 22

Expert Comment

by:nietod
ID: 1163100
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.
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1163101
To dissable name mangeling, you must declare a function as extern "C".    Like

extern "C" bool Passed(char *Param1,char *Param2)
{
   . . .
};

Does that help?  If not let me know.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Matlock
ID: 1163102
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
0
 
LVL 22

Expert Comment

by:nietod
ID: 1163103
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.)
0
 

Author Comment

by:Matlock
ID: 1163104
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
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now