Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. COM Client problem

COM Client problem

Scheduled Pinned Locked Moved COM
comhelp
8 Posts 5 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    YSRao
    wrote on last edited by
    #1

    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

    V B D 5 Replies Last reply
    0
    • Y YSRao

      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

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Did you register the COM server to registry? What is the error? Kuphryn

      A 1 Reply Last reply
      0
      • Y YSRao

        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

        B Offline
        B Offline
        balcn
        wrote on last edited by
        #3

        Did you use the ATL wizard? What is the error yu get? R.Balachandran

        A 1 Reply Last reply
        0
        • B balcn

          Did you use the ATL wizard? What is the error yu get? R.Balachandran

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • V valikac

            Did you register the COM server to registry? What is the error? Kuphryn

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            hi, yah registered COM Server to registry. atlwin.h requires atlbase.h to be included first

            1 Reply Last reply
            0
            • Y YSRao

              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

              V Offline
              V Offline
              valikac
              wrote on last edited by
              #6

              Include the .h file that ATL's MIDL generated and the .h file from of the coclass. Kuphryn

              1 Reply Last reply
              0
              • Y YSRao

                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

                B Offline
                B Offline
                balcn
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                • Y YSRao

                  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

                  D Offline
                  D Offline
                  Dudi Avramov
                  wrote on last edited by
                  #8

                  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();
                  }

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups