Link to home
Start Free TrialLog in
Avatar of c095276
c095276

asked on

using VC++ dll in VB

I wrote a dll in VC++ 6.0, and using it in VB 6.0.  I get an error when trying to set a reference to it.  What do I need to do to make it work properly with VB?  Example would be helpful.
Avatar of jhance
jhance

Two things:  

1) In your VC++ DLL, you must specify all the exported function as:

extern "C" __declspec(dllexport)

and also __stdcall

So a typical function declaration would be:

extern "C" __declspec(dllexport) void __stdcall ExportedFunctionName(void);


2) In your VB program, you need this.

Private Declare Function ExportedFunctionName Lib "YourDll.dll" Alias "_ExportedFunctionName@0" ()

The "@0" at the end varies depending on the number and type of the arguments to the function.  If in doubt, check the DLL's ACTUAL names with DUMPBIN /EXPORTS
Avatar of c095276

ASKER

I have already done this.  What I want to know is, can I set a reference to my dll under projects->references, so that someone can use the object browser to view its interface?  If so, how is it done?
No
U annot do that unless its a type library or ActiveX for .dll U have to follow what jhance has told
Avatar of c095276

ASKER

I was looking in MSDN library, and ran across this

"Code objects into a compiled .c or .cpp file so they can be accessed using IDispatch::GetTypeInfo or implementations of the ITypeInfo and ITypeLib interfaces."

Is there any good examples of doing either of these?

Thanks
But what does "DUMPBIN /EXPORTS" show?


ASKER CERTIFIED SOLUTION
Avatar of jhance
jhance

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
c095276,

Next time, keep your points!