Solved

using VC++ dll in VB

Posted on 2000-02-14
7
195 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find Visual Studio Tools 2 121
How to gracefully close the c++ 11 thread? 3 122
computer science syllabus 3 100
trigs fail! I thought I knew how to do trignometry 3 82
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

735 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