Click to See Complete Forum and Search --> : start VB DLL in C++EXE
BarankinBeAMan
Aug 7th, 2002, 02:51 PM
How do I start VB DLL in C++EXE in debug mode?
If I run EXE, it calls VB dll with no problem.
But in VB debug mode, when I start vb application,
C++ executable starts with no problem, then when I call vb DLL from there, I get error, dll does not get created.
Is that VB known bug or me doing it wrong ?
:confused: :eek: :confused:
jim mcnamara
Aug 8th, 2002, 09:29 AM
VB dll's require the VB run-time & VB virtual machine to be activated, plus, VB-made dll's are COM objects, so you have to call CoInitialize();
BarankinBeAMan
Aug 8th, 2002, 09:38 AM
Here is what I do:
HRESULT hresult;
CLSID clsid;
CoInitialize(NULL); //initialize COM library
hresult=CLSIDFromProgID(OLESTR("ValidateCard.Validate"), &clsid); //retrieve CLSID of component
_Validate *t;
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_Validate),(LPVOID *) &t);
if(FAILED(hresult))
{
AfxMessageBox("Creation Failed");
return;
}
______________________________________________
and this works fine when I run C++ code.
But it Failes to create object if I run it from vb Code.
How do you run it from vb to debug it ?
:eek: :eek:
jim mcnamara
Aug 8th, 2002, 09:54 AM
In your VB project, set a reference to the .dll, .OCX or .EXE.
Dim vcard as New Validate ' assuming the class name is validate
............... mess with it here
Is this what you mean?
You can check to make sure what the class is by using F2 - the Object Browser, after you have added the reference.
BarankinBeAMan
Aug 8th, 2002, 10:24 AM
The problem is, in vb debug mode, vb class function does not even get called.
C++ exe gets executed first, and before it even calls
vb function, it fails to create vb object.
But while running the same compiled VB dll and calling the same vb function, the object creation does not fail.
There has to be some way to run VB code in debug mode successfully.
:confused: :confused: :confused:
CornedBee
Aug 13th, 2002, 06:04 AM
You could create a small VB exe for test purposes only.
BarankinBeAMan
Aug 13th, 2002, 08:12 AM
I tried that, It works fine with VB exe too, as well as in Debug mode.
I think in case of using C++ exe and VB dll in debug mode,
there has to be some options in C++ project, or some certain dll declaration in c++, so VB function could be called not only in run time, but in debug mode too. :eek: :eek: :confused:
BarankinBeAMan
Aug 13th, 2002, 08:47 AM
Binary Compatability option in VB project properties
had to be checked.
Now it works.
Otherwise, VB function never gets called in Design Mode.
:D :D :D :D :D
tumblingdown
Aug 14th, 2002, 08:07 AM
I'm sure you're aware of this, but if you compile your vb project with debug symbols, you can step thru the vb code from the c++ debugger.
td.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.