Solved

VB Migration

Posted on 2000-05-04
2
236 Views
Last Modified: 2010-04-02
The problem: Using an ActiveX dll

In VB, in the references dialog y can select any registered dll such as 'Olemsg.dll'.
Then in any piece of code i can instantiate objects exposed in the library using a simple and cheap Dim statement e.g.:
Dim obj As MAPI.Recipient
'or
Set obj = CreateObject("MAPI.Recipient")


How do I do the same in C++? I'm using VC++ 6.0

Thanks
0
Comment
Question by:trillo
[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 Comments
 
LVL 2

Expert Comment

by:vbk_bgm
ID: 2779921
You need to derive a class from the type library (View -> ClassWizard and Add new class from the type lib). Select the classes that you need for your app.
Then you could create object using CreateDispatch and delete using ReleaseDispatch
For instance, if you are creating for Excel Automation.
m_Excel.CreateDispatch(Excel.Application);
where mExcel is of type Application in this case.
0
 

Accepted Solution

by:
MUpchu777 earned 50 total points
ID: 2794932
If your talking about COM Objects (which is what I see in your example), the easiest solution is to use the #import statement.  The syntax is #import "<name of dll or tlb file here>".  There are a few other parameters, but that is the basic gist.  VC will wrap the COM object with smart pointer classes that handle referencing and dereferencing for you.  THis is a highly recommended way to work with COM Objects in VC.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ question 3 74
How to remove Recent Projects from Embarcadero C++ builder XE10. Berlin 2 78
Need some help with mailto 16 34
C++ Code Issue 4 38
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

733 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