Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to access vb dll in c++ builder ?

Posted on 2002-04-16
9
Medium Priority
?
388 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 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.
Suggested Courses

610 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