Solved

using VC++ dll in VB

Posted on 2000-02-14
7
199 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
Industry Leaders: 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

689 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