Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing an ATL Project in VC++ 2005 to use as ActiveX in VB6. I added methods, properties and events following the steps in this tutorial: A Beginner Tutorial for Writing Simple COM/ATL DLL and Using it with .NET [^]. Everything is working fine while I'm working inside the class. But now I need to call an event or method of the class but from a global method?

How can I do this?

Thanks.
Posted
Updated 28-Nov-11 1:25am
v2

What language do you want to make the call from a global function?

If you mean VB6, you will need to reference your new COM object in your VB6 project, and create an instance of the COM object like this:


VB
Dim objA as New YourATLComObjectName

objA.YourFunction()


If you mean C++, you will need to call ::CoCreateInstance with the GUID for your object.

The two things you will need in place to make sure your VB project can see the object:

1) The DLL needs to be registered which happens by default when VS compiles it. When you install it on a users machine you use regsvr32.
2) The DLL needs to be referenced as one of the resources that you bring into your project.
 
Share this answer
 
Please use the forum at the end of the article so the author can see it.
 
Share this answer
 
Use scope resolution operator ( :: ) to access the global variables
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900