CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2016
    Posts
    10

    Can COM server can call method inside MFC Client ?

    Hi,

    Apart from Connection points, Is there any other way a Method inside my COM server can call method inside MFC Client ?

    Please Suggest...

    Thanks,
    Abhilash

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Can COM server can call method inside MFC Client ?

    In case your COM server is in-proc server, and your MFC Client exports the required function, the function can be called from server by means of dynamic linking (GetProcAddress). However, this makes your COM server be useless with other clients.

    Another option is passing some raw interface pointer (C/C++ struct) directly via COM method to server. A dangerous way, but possible one.

    And in case of out-of-proc server the tricks above are impossible.
    Last edited by Igor Vartanov; March 2nd, 2016 at 07:57 AM.
    Best regards,
    Igor

  3. #3
    Join Date
    Mar 2016
    Posts
    10

    Re: Can COM server can call method inside MFC Client ?

    Thanks Igor for your reply...

    From your inputs, I have decided the below way to get data from my COM server.

    Sending a structure from MFC client to my COM server, so COM server will update the structure and send it back. Please let me know is that fine ?

    I have tried below so far...

    My IDL file...(COM server)

    typedef
    [
    uuid(C5A89C1D-630E-4542-84BA-7E6AC9517DFF),
    version(1.0),
    ]
    struct UDTVariable {
    [helpstring("Special case variant")] VARIANT Special;
    [helpstring("Name of the variable")] BSTR Name;
    [helpstring("Value of the variable")] long Value;
    } UDTVariable;


    [id(1)] HRESULT UpdateResult([out] struct UDTVariable *result);




    Inside MFC Client....


    struct UDTVariable {
    VARIANT Special;
    BSTR Name;
    long Value;
    } UDTVariable;

    UDTVariable obj;

    COMptr->UpdateResult(reinterpret_cast<void*>(&obj)); (COMptr has a reference to COM server)

    But Iam getting compilation error..."type mismatch"


    Can you please help me to form the proper syntax.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Can COM server can call method inside MFC Client ?

    Hardly I can follow what you're trying to accomplish. But in case you want to pass some composite object to COM server and back, why don't you make it be a regular COM object?
    Best regards,
    Igor

  5. #5
    Join Date
    Mar 2016
    Posts
    10

    Re: Can COM server can call method inside MFC Client ?

    Thanks Igor,,,

    Will try out the same..

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured