Solved

How to use ATL COM object created in VC++ in another ATL COM object in VC++

Posted on 2003-11-12
3
680 Views
Last Modified: 2013-12-14
I have ATL COM created in MS  Visual C++ 6.0, now I would like to use that in the different ATL COM object. How do I do it? Are there any changes to existing ATL Object in order to make it usable in a new ATL object? What do I have to do to get functionality of first ATL object in the second ATL object. I have a source code for first object and .dll and .lib files.

More details please.
0
Comment
Question by:germaks
[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
  • 2
3 Comments
 
LVL 19

Expert Comment

by:Dexstar
ID: 9735938
germaks:

> I have ATL COM created in MS  Visual C++ 6.0, now I would like to use that in
> the different ATL COM object. How do I do it? Are there any changes to existing
> ATL Object in order to make it usable in a new ATL object? What do I have to
> do to get functionality of first ATL object in the second ATL object. I have
> a source code for first object and .dll and .lib files.

I would do it like this.  In a header file for your new ATL object, add this:

     #import "<PATH>\ObjectOne.dll" no_namespaces

(Where <PATH> and ObjectOne point to your original DLL file).

Then, here is some sample code of using your object (called YourObject, in this example).  Be sure to wrap your code in try/catch blocks to catch _com_error& e's.

     try
     {
          IYourObjectPtr spObject;

          spObject.CreateObject( __uuidof(YourObject) );
          spObject->SomeMethod();
     }
     catch ( _com_error& e )
     {
          // Handle the error
     }


Hope that helps,
Dex*
0
 

Author Comment

by:germaks
ID: 9736532
It almost works,
when I compile it I get the error that CreateObject is not a member of '_com_ptr_t<class _com_IIID<struct IVerify,&struct __s_GUID _GUID_bc555c18_f885_4b65_aebf_683ba81cc964> >'

here is the code

IVerifyPtr LicV;
LicV.CreateObject( __uuidof(Verify) );
0
 
LVL 19

Accepted Solution

by:
Dexstar earned 500 total points
ID: 9741275
germaks:

Oops.  My mistake.  This line should be this:
     LicV.CreateInstance( __uuidof(Verify) );

(It's a hazard of going back and forth between VB and C++ all day...)

Dex*
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
windbg taking it's time 32 107
fatal error: vector: No such file or directory   Visual Studio 2015 for Arduino 4 119
C++ help/ Toy problem 19 69
import as existing maven project 3 77
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

734 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