?
Solved

How to access vb dll in c++ builder ?

Posted on 2002-04-16
9
Medium Priority
?
384 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
[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
  • 3
  • 2
9 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 30 total points
ID: 6944491
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
ID: 6945712
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
ID: 6945789
>>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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:pellep
ID: 6946048
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
 
LVL 1

Author Comment

by:yamiho
ID: 6946737
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
ID: 6946770
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
ID: 6946782
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
ID: 6946806
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
ID: 6947412
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

770 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