你可以定义两个static对象啊,主程序用一个,组件用一个,干吗非得把组件放到另一个进程空间。放到另一个进程空间的做法是,创建COM对象的项目时不要选择进程内,选择EXE或者服务都可以。

解决方案 »

  1.   

    up,这需求怪怪的...
    干吗非得把组件放到另一个进程空间
    搞成cs了
      

  2.   

    为什么必须是Static的定义?
      

  3.   

    When a non-inproc activation request first occurs for a CLSID, the SCM uses the following precedence rules to decide what to launch:   1. If the AppID has a LocalService named value, COM uses the OpenSCManager/StartService APIs to start the server.
       2. If the CLSID has a LocalServer32 entry, COM starts the designated process using CreateProcess or CreateProcessAsUser.
       3. If the AppID’s DllSurrogate named value is present yet empty, a system-provided surrogate process (dllhost.exe) is started.
       4. If the AppID’s DllSurrogate named value is present and contains a file name, the designated custom surrogate is started.
       5. If the AppID’s RemoteServerName named value is present, the request is forwarded to the SCM on the designated host.From: http://www.microsoft.com/msj/0597/activex0597.aspx