Solved

using VC++ dll in VB

Posted on 2000-02-14
7
192 Views
Last Modified: 2010-04-02
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.
0
Comment
Question by:c095276
7 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 2518519
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
0
 

Author Comment

by:c095276
ID: 2518550
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?
0
 
LVL 4

Expert Comment

by:inpras
ID: 2518612
No
U annot do that unless its a type library or ActiveX for .dll U have to follow what jhance has told
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:c095276
ID: 2518734
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
0
 
LVL 1

Expert Comment

by:mahno
ID: 2519219
But what does "DUMPBIN /EXPORTS" show?


0
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 2519588
>"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?


You're either mixing your technologies or not telling us the full story.  IDispatch is the way of calling functions on a COM Automation interface.  While this can be implemented in a DLL, a DLL is not necessarily a COM object.  Further, a COM object doesn't necessarily have a Automation interface.

What I've already told you is correct.  Go back and check your work!


>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?

Again, this doesn't apply to your situation unless you're talking about a COM or ActiveX component.  You said, and I quote: "I wrote a dll in VC++ 6.0".  You DIDN'T say, "I've written an ActiveX component".



0
 
LVL 32

Expert Comment

by:jhance
ID: 2522262
c095276,

Next time, keep your points!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now