Solved

DLL's GetProcAddress() cont'd to nietod

Posted on 1998-04-22
6
226 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

776 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