?
Solved

How to use COM Objects in MFC application

Posted on 2009-12-28
6
Medium Priority
?
746 Views
Last Modified: 2013-12-14
Hi

I am working on hMailServer. hMailServer delivers COM Objects to be used  
http://www.hmailserver.com/documentation/latest/?page=com_objects

I have one MFC Application. From MFC Application, I would like to access COM objects. Is that possible? Any inputs?

Regards,

Yogesh




0
Comment
Question by:yogithite
  • 3
  • 2
6 Comments
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 26135827
I hope, in the standard way - add ATL support to your project, then create an object and take interface from it:
1. CoInitialize
2. CoCreateInstane
3. QueryInterface

Here you can find a lot of info (also about MFC and about other way to use COM in the MFC application):
http://msdn.microsoft.com/en-us/library/ms877981.aspx

Here is an article on CodeProject:
http://www.codeproject.com/KB/COM/comintro.aspx
0
 
LVL 8

Expert Comment

by:Pramod Bugudai
ID: 26136010
0
 

Author Comment

by:yogithite
ID: 26136031
Hi Pramod,

I am trying to access COM Objects mentioned in link:

http://www.hmailserver.com/documentation/latest/?page=com_objects

Can anyone provide me sample code for this? Atleast which class ID CLSID_ i should use to access hMailServer object?

Regards,

Y
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 33

Expert Comment

by:pgnatyuk
ID: 26136065
I think it should be something like that:

#import "C:\Program Files\hMailServer\Bin\hMailServer.tlb"

// Initialize COM support
CoInitialize(NULL);

// Create the hMailServer Application object
hMailServer::IInterfaceApplicationPtr pApp;
pApp.CreateInstance(__uuidof(hMailServer::Application) );
0
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 2000 total points
ID: 26136074
0
 

Author Closing Comment

by:yogithite
ID: 31670658
A million thanks straight-from-the-heart :-)you saved my day

Thanks again!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 and create keystrokes in Netbeans IDE 8.0 for Windows.

840 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