Solved

using VC++ dll in VB

Posted on 2000-02-14
7
196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

732 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