2010-01-08 6 views
0

나는 .NET EXE와 ATL COM EXE가 Windows Mobile에있다. 나는 그들 사이에서 의사 소통을해야합니다. 예 : 내 ATL EXE가 .NET EXE를 시작합니다. .NET EXE는 처리가 완료되거나 종료되었다는 메시지를 ATL EXE에 보내야합니다. 어떻게해야합니까?.NET EXE와 COM EXE간에 통신하는 방법은 무엇입니까?

두 개의 서로 다른 프로세스간에 통신하는 방법은 무엇입니까?

답변

0

Windows 메시지를 사용할 수 있습니다. 자세한 내용은 blog post을 참조하십시오.

+0

안녕하세요 저는 특정 이름의 단일 창이 있다면 창 메시지를 사용해 보았습니다. 하지만 같은 이름의 창이 여러 개 있다면 어떻게 될까요? – Naruto

1

편집 :

질문 모바일에 대한 것을 놓쳤다. 이것이 작동하는지 모르겠다.

static class IpcChannelManager<T> { 
    /// <summary> 
    /// Make a type available to other processess 
    /// </summary> 
    /// <param name="type"> 
    /// Type to register, must derive from MarshalByRefObject and implement <typeparamref name="T"/> 
    /// </param> 
    /// <param name="portName">Name of IpcChannel</param> 
    public static void RegisterType(Type type, string portName) { 
     if (!type.IsSubclassOf(typeof(MarshalByRefObject))) 
      throw new ArgumentException("Registered type must derive from MarshalByRefObject"); 
     Dictionary<string, string> ipcproperties = new Dictionary<string, string>(); 
     ipcproperties["portName"] = portName; 
     // Get the localized name of the "Authenticated users" group 
     ipcproperties["authorizedGroup"] = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null).Translate(typeof(NTAccount)).ToString(); 

     ChannelServices.RegisterChannel(new IpcServerChannel(ipcproperties, null), false); 
     RemotingConfiguration.RegisterWellKnownServiceType(type, typeof(T).Name, WellKnownObjectMode.Singleton); 
    } 

    /// <summary> 
    /// Get a reference to a remoting object 
    /// </summary> 
    /// <param name="portName">Name of Ipc port</param> 
    /// <returns> 
    /// Reference to remote server object</returns> 
    public static T GetRemoteProxy(string portName) { 
     ChannelServices.RegisterChannel(new IpcClientChannel(), false); 
     return (T)Activator.GetObject(typeof(T), "ipc://" + portName + "/" + typeof(T).Name); 
} 

을 그리고 I는 다음과 같이 사용 :

나는이 헬퍼 클래스와 함께 IPC 채널을 사용 양쪽에 사용할 수

인터페이스

interface IIpcMessage { 
    int GetSomeData(string foo); 
} 

를 수신 측에 할 수

class IpcMessage : MarshalByRefObject, IIpcMessage { 
    ... 
} 

IpcChannelManager<IIpcMessage>.RegisterType(typeof(IpcMessage), "Someuniqueportname"); 

그리고 보낸 끝에 0 :

IIpcMessage ipcMessage = IpcChannelManager<IIpcMessage>.GetRemoteProxy("Someuniqueportname"); 

int data = ipcMessage.GetSomeDate("blabla"); 
+0

Windows Mobile/Windows CE에서 작동하지 않습니다 – ctacke

1

CreateProcess를 프로세스 핸들을 반환 할 수 있습니다. WaitForSinbleObject 만 있으면 .NET 프로세스가 종료 될 때 신호를받습니다.

+0

안녕하세요, 명령 줄에서 이벤트 핸들을 전달할 수 있어야합니까? 가능합니까? – Naruto

+0

예, 명령 줄에 물건을 전달할 수 있습니다. 그러나 값을 처리하지는 않지만 해당 값은 해당 값을 생성 한 프로세스에서만 유효합니다. –

+0

안녕하세요 .. 명령 줄에서 문자열을 바로 전달할 수 있습니다 .. 어떻게하면 이벤트 핸들을 전달할 수 있습니까? – Naruto

관련 문제