Solved

How to access vb dll in c++ builder ?

Posted on 2002-04-16
9
373 Views
Last Modified: 2010-04-02
Hi

How to access dll which is created using vb in my c++ builder code. ? Does anybody have a sample program or link on the net. ? Please help me out.

Thanks and Regards
YamihO
0
Comment
Question by:yamiho
  • 4
  • 3
  • 2
9 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 10 total points
Comment Utility
Three things:

1) Load the DLL from your C++ code using LoadLibrary().

For example:

HMODULE hMod = LoadLibrary("MYDLL.DLL");
if(hMod == NULL){
  // An error, do something about it....
}

2) Find the functions in the DLL you want to use with GetProcAddress().

For example:

FARPROC pProc = GetProcAddress(hMod, "MyDllFunction");
if(pProc == NULL){
  // An error, do something about it...
}

3) Call the functions as needed.

For example:

pProc();

0
 
LVL 4

Expert Comment

by:pellep
Comment Utility
Well, jhance is not entirely correct. VB DLL's are ActiveX dll's and are accessible using the COM functionality. At least in VC++ there is a wizard that uses the typelib of the ActiveX dll and autmatically creates helper classes to access the different functions.
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
>>VB DLL's are ActiveX dll's

Not true.  There is absolutely NO requirement that any VB DLL be ActiveX or COM.  Granted, VB can and will make COM/ActiveX DLLs but I see no mention of that above.

And in fact, the same argument can be made for ANY DLL regardless of what tool developed it.  A DLL MAY be a "straight" DLL, it may be a COM INPROC server, or it may be an ActiveX or some other automation object.
0
 
LVL 4

Expert Comment

by:pellep
Comment Utility
Ok, I haven't used VB since VB 6.0, but back then at least, VB could only produce ActiveX dll's. Can you build regular windows dll's in VB now?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:yamiho
Comment Utility
yes jhance, so far i know. Dll is a straight Dll. You can call in most of the programming langauges. But the problem is i donno how to call a dll. can u gimme one example please

thanks
YamihO
0
 
LVL 1

Author Comment

by:yamiho
Comment Utility
yes jhance, so far i know. Dll is a straight Dll. You can call in most of the programming langauges. But the problem is i donno how to call a dll. can u gimme one example please

thanks
YamihO
0
 
LVL 1

Author Comment

by:yamiho
Comment Utility
yes jhance, so far i know. Dll is a straight Dll. You can call in most of the programming langauges. But the problem is i donno how to call a dll. can u gimme one example please

thanks
YamihO
0
 
LVL 1

Author Comment

by:yamiho
Comment Utility
hi

i've written the code what you've given to me.

Code :
------

    HMODULE hMOD = LoadLibrary("MxDll.dll");
    if(hMOD == NULL)
        ShowMessage("Can't access the Dll");
    else
    {
        FARPROC pProc = GetProcAddress(hMOD, "WantToSave");
        if(pProc == NULL)
            ShowMessage("Can't access the function");
        else
            pProc();
    }

MxDll.Dll is the dll
WantToSave is the Function written in that Dll.

The thing is I can access the dll but can't access the function. it is prompting 'Can't access the function'

Thanks in adv. for help.
Regards
YamihO
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
If GetProcAddress() is failing then you are using the wrong name.

Use the DUMPBIN utility to find out the proper name for the export function like:

DUMPBIN /EXPORTS MXDLL.DLL

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

728 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

10 Experts available now in Live!

Get 1:1 Help Now