CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2003
    Location
    India
    Posts
    196

    Commnuication across individual process...need suggestion

    Hello All,

    Need some suggestion on how to proceed with the following situation:

    I have a MDI Based Application "xxx.exe" in which we incorporated OLE layer such that the application can be invoked and communicated through the MS Excel too. Now xxx.exe invokes some zzz.DLL / some yyy.exe through CreateProcess (for launching .exes) methods, and i have requirement such that this zzz.dll or yyy.exe should be able to talk to xxx.exe and get some data from xxx.exe.

    I was thinking whether i can achieve this through the existing OLE layer in xxx.exe or I should introduce some COM Layer in this xxx.exe and expose some interfaces such that the application like yyy.exe or zzz.dll can exchange data to and fro with xxx.exe.

    Any suggestions in this scenario.

    Thanks
    Intellectuals solve problems; geniuses prevent them.--Albert Einstein.

    Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute.THAT'S Relativity --Albert Einstein

  2. #2
    Join Date
    Sep 2003
    Location
    India
    Posts
    196

    Re: Commnuication across individual process...need suggestion

    Does using CConnectionPoint will be a good solution.

    -venky
    Intellectuals solve problems; geniuses prevent them.--Albert Einstein.

    Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute.THAT'S Relativity --Albert Einstein

  3. #3
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Commnuication across individual process...need suggestion

    If your intention is to communicate between two processes without communicating with other OLE objects, consider pipe or socket.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  4. #4
    Join Date
    Sep 2003
    Location
    India
    Posts
    196

    Re: Commnuication across individual process...need suggestion

    i tried working out this way
    HTML Code:
    http://www.codeguru.com/forum/showthread.php?p=1757054#post1757054
    but still no luck in resolving this issue...any suggestions...
    Intellectuals solve problems; geniuses prevent them.--Albert Einstein.

    Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute.THAT'S Relativity --Albert Einstein

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Commnuication across individual process...need suggestion

    Quote Originally Posted by venkyhyd
    i tried working out this way
    HTML Code:
    http://www.codeguru.com/forum/showthread.php?p=1757054#post1757054
    but still no luck in resolving this issue...any suggestions...
    You are only complicating things by bringing in C# into the mix.

  6. #6
    Join Date
    Sep 2003
    Location
    India
    Posts
    196

    Re: Commnuication across individual process...need suggestion

    Quote Originally Posted by Arjay
    You are only complicating things by bringing in C# into the mix.

    Okay now here i have situation, i have an MFC MDI Based application with OLE Automation layer in it. I will launch this MFC and i have a C# application which is invoked by this MFC application through the create process methdo and want this C# application to talk to the MFC application and exchange data between these two.

    Can the existing OLE layer in the MFC application be used for exchanging data across these two applications.

    Please suggest me if i am missing anything here or messing up with things
    Intellectuals solve problems; geniuses prevent them.--Albert Einstein.

    Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute.THAT'S Relativity --Albert Einstein

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Commnuication across individual process...need suggestion

    I don't know the answer to your question about using OLE layer, however, you could easily implement communications using (as JohnCz already mentioned) pipes or sockets. Since you run both Apps on the same PC you could also use WM_COPYDATA message (and if data to be sent were not so big and communications happened not so oft - just a simple PostMessage a registered Windows messages could work)
    Victor Nijegorodov

  8. #8
    Join Date
    Sep 2003
    Location
    India
    Posts
    196

    Re: Commnuication across individual process...need suggestion

    I think i have a solution for this, still need your valuable comments on this solution.

    In the MFC Ole Server app i created an interface (deriving a class from CDocument or CCmdTraget). In the server before invoking the C# client I would instantiate the Interface in the appliction itselfs such that client need not do any CoCreateInstance on the interface, instead the client can just do a QueryInterface and get handle to the Interface and try talkting to the application.

    Now how does the client get handle to application, so for this I would add this MFC Ole Server application to the ROT with ItemMoniker giving the name of the application and whatever string information which is easy to identify by the client. Now the client would parse through the entire ROT table and get handle to Application and do a GetObject and just

    C# client code: to get handle to Ole app
    Code:
        Ole32.GetRunningObjectTable(0, out runningObjectTable);
                runningObjectTable.EnumRunning(out pMonkEnum);
                pMonkEnum.Reset();  
            
                IntPtr fetched = Marshal.AllocHGlobal(4);
                IMoniker[] pMon = new IMoniker[1];
                IMoniker pClientMoniker;
                Object ppUnkVFObj;
                
               
                string objList = "";// = new string();
                string objOut = "From C# client: Hello I am from C# Client";
                //test MFC Ole Server functionality strings
    
                while (pMonkEnum.Next(1, pMon, fetched) == 0)
                {
                    int iFetched = Marshal.ReadInt32(fetched);
                    IBindCtx pCtx;
                    Ole32.CreateBindCtx(0, out pCtx);
                    string str;
                    pMon[0].GetDisplayName(pCtx, null, out str);
                    if (str.CompareTo("OLESERVERNAME") == 0)
                    {
                        pClientMoniker= pMon[0];
                        runningObjectTable.GetObject(pClientMoniker, out ppUnkVFObj);//ppUnkVFOb is of type Object
                        vfAutomationFunct = (MFCApp.IExposeFunct)ppUnkVFObj; //Note i am not doing any cocreateinstance here instead just doing a getobject and type casting it to the interface type.
                        vfAutomationFunct.GetObjectList(ref objList); //these functions are defined in the Interface present in the MFC Ole server exe
                        vfAutomationFunct.SetObjData(objOut);   //these functions are defined in the Interface present in the MFC Ole server exe
                    
                    }
                }
    Any comments/suggestions on the above said?

    -thanks
    Intellectuals solve problems; geniuses prevent them.--Albert Einstein.

    Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute.THAT'S Relativity --Albert Einstein

  9. #9
    Join Date
    Sep 2003
    Location
    India
    Posts
    196

    Re: Commnuication across individual process...need suggestion

    I would really appreciate your inputs on the solution i had thought of....


    -thanks in advance
    Intellectuals solve problems; geniuses prevent them.--Albert Einstein.

    Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute.THAT'S Relativity --Albert Einstein

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