COM Client problem
-
Hi, I am learner of COM Technology.I have written simple com object.It has 3 methods.I compiled it successfully.But the problem is I have written client program,it is showing errors. i have included component's .h,_i.c files into client program CoInitialize(NULL); CoCreateInstance(..........); what are the steps to follow to write COM Client program. yakkalas
-
Hi, I am learner of COM Technology.I have written simple com object.It has 3 methods.I compiled it successfully.But the problem is I have written client program,it is showing errors. i have included component's .h,_i.c files into client program CoInitialize(NULL); CoCreateInstance(..........); what are the steps to follow to write COM Client program. yakkalas
-
Hi, I am learner of COM Technology.I have written simple com object.It has 3 methods.I compiled it successfully.But the problem is I have written client program,it is showing errors. i have included component's .h,_i.c files into client program CoInitialize(NULL); CoCreateInstance(..........); what are the steps to follow to write COM Client program. yakkalas
-
I have created Arthematic simple object. in Client program i write like this. CoInitialize(NULL); IArthematic *art; CoCreateInstance(CLSID_Arthematic,NULL,CLSCTX_INPROC_SERVER,IID_Arthematic,reinterpret_cast&iu); And when compiling, compiler shows atlwin.h require atlbase to be included first. I have included Arthematic.h and MyCom_i.c files in my client program. how can I get out of this and plz tell me how to write client program for a simple object.
-
Hi, I am learner of COM Technology.I have written simple com object.It has 3 methods.I compiled it successfully.But the problem is I have written client program,it is showing errors. i have included component's .h,_i.c files into client program CoInitialize(NULL); CoCreateInstance(..........); what are the steps to follow to write COM Client program. yakkalas
-
Hi, I am learner of COM Technology.I have written simple com object.It has 3 methods.I compiled it successfully.But the problem is I have written client program,it is showing errors. i have included component's .h,_i.c files into client program CoInitialize(NULL); CoCreateInstance(..........); what are the steps to follow to write COM Client program. yakkalas
Here I have given a sample working code for a COM client // COMClientDlg.cpp : implementation file #include "stdafx.h" #include "COMClient.h" #include "COMClientDlg.h" #include "COMServer.h" #include "COMServer_i.c" ............................ ............................ ............................ HRESULT hr; IMessage *msg; hr = CoInitialize(0); //initialize COM if( SUCCEEDED(hr) ) { hr = CoCreateInstance( CLSID_Message, NULL, CLSCTX_INPROC_SERVER, IID_IMessage, (void **)&msg ); if( SUCCEEDED(hr) ) { msg->Show(); msg->Release(); } else { AfxMessageBox("Cannot create COM object"); } CoUninitialize(); //uninitialize COM } else { AfxMessageBox("Cannot initialize COM"); } This code worked fine when I tested under an MFC dialog project. The server was created as a DLL by the ATL wizard. While creating a simple object the following options were selected. Threading Model - apartment Interface - dual Aggregation - yes If you still have trouble you can mail your code to me R.BALACHANDRAN
-
Hi, I am learner of COM Technology.I have written simple com object.It has 3 methods.I compiled it successfully.But the problem is I have written client program,it is showing errors. i have included component's .h,_i.c files into client program CoInitialize(NULL); CoCreateInstance(..........); what are the steps to follow to write COM Client program. yakkalas
You should use #import directive and smart pointers. It makes everything simple for developing COM client. For example, if you have COM object named Message then do the following: #import "Message.tlb" no_namespace
void main()
{
CoInitialize(NULL);
try
{
IMessagePtr pMessage = IMessagePtr(__uuidof(Message));
pMessage->Method();
}
catch(_com_error &e)
{
HRESULT hr = e.Error();
}
CoUninitialize();
}