Solved

using VC++ dll in VB

Posted on 2000-02-14
7
191 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

705 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

15 Experts available now in Live!

Get 1:1 Help Now