Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DLL's GetProcAddress() cont'd to nietod

Posted on 1998-04-22
6
Medium Priority
?
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

715 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