Solved

How to access vb dll in c++ builder ?

Posted on 2002-04-16
9
376 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
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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 72
C language IDE – Compilers installation 14 71
Getting IP address 8 79
How to print into std::string like sprintf using C++11? 12 61
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…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

803 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