Solved

How to access vb dll in c++ builder ?

Posted on 2002-04-16
9
383 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 10 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
Technology Partners: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

729 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