VB vs C++ DLL

Previous topic - Next topic

matchy

Has anyone called a VB DLL from GLB? I've tried but can't get it to work, if I've done it properly. Otherwise I think the solution is to inline call a VC++ DLL which then internally calls the VB DLL, which I wanted to try.

Beginner's Tutorial: Calling Visual Basic ActiveX DLLs from Visual C++  :rtfm:
http://www.codeproject.com/Articles/21/Beginner-s-Tutorial-Calling-Visual-Basic-ActiveX-D

Kitty Hello

Oh. ActiveX is different to call.
I'm no expert here.

matchy

Isn't ActiveX class dlls for VB6? I have just tried with VS VB Express 2010, by compiling a simple class dll. In the tutorial post you mention dependency walker. The dll I create does not show any function names so I wonder if it should here. I have tested the dll by calling it from a vb exe and it works but it's too hard or I just can't with GLB because there is no function/entry point. I have tried a VS C++ 2012 dll and the function name does appears in dependency walker.

MrTAToad

You have got to know about the innards of a VB DLL to use it unfortunately - if it hasn't exported any functions (and thus not being displayed in Dependency Walker) then there isn't much you can do.

This site (http://ccc.panitzco.com/mpanitz/COM_Tutorial/COMClientInC.html) has the basis for the proper way of doing it

matchy

This is what I was afraid of for any version of VB and thus my original plan was to call it (COM) from C++, so thanks for the link.  :sick:

For one of many practical purposes example, I would like to open (eg. MS Access database) in VB called by VSC++ called by GLB.  :zzz:

hardyx

#5
matchy, ActiveX dlls are "special" classes because you can't view any functions in the DLL. The functions are in a special area called TLB (IDL), with defines the interfaces. You create an object with CoCreateInstance and then use the interface to call the functions. VB manages the interfaces, functions and properties automatically, but in VC++ you can call many COM functions.

CoCreateInstance : creates a component
Release : release (free) a component
QueryInterface : request an interface from a component
interf->method() : calls a method
interf->get_prop()  : reads a property
interf->put_prop() : writes a property

Visual C++ creates a wrapper class for calling methods and properties reading the COM dll, and extracting the TLB. I recommend you create the wrapper because is *VERY* difficult to manage this without the wrapper (you must to work with large UUID numbers and identificators).

P.D. You can view the components and interfaces in a COM DLL with the "COM Object Viewer" tool. It's shipped with Visual C++. http://msdn.microsoft.com/en-us/library/d0kh9f4c%28v=vs.80%29.aspx.

hardyx

#6
I think you can create a regular DLL in VB to manage the COM objects, and this DLL can be called from GLBasic. It's more easy in VB than C++, because the language manage the references and the interfaces. I'm speaking about VB6, not VB.Net.

matchy

That sound positive as I have tried to create a dll in vb6 in glbasic because it's easier than including c++, hence why I haven't progressed.