描述:
以前学的时候好像记得,对于一些只使用了VARIANT中的类型的接口不需要自己的proxy stub,windows有一个缺省的proxy stub可以使用。
我的问题是如果我的接口方法中使用了另一个我自己定义的接口作为参数,那么这时需不需要自己的proxy stub?如下
interface IMyInterface;
interface IMyInterface2
{
....
HRESULT GetInterface(IMyInterface** ppInterface);
}
当创建实现了IMyInterface2的组件时需不需要同时创建其proxy stub?还是使用windows缺省的那个就可以了?
解决方案1:
呵呵,从google搜到这儿来了,一般来说不用自己去实现proxy/stub代码,因为你只有定义好了idl/odl文件,MIDL编译器会替你的接口生成proxy/stub代码
解决方案2: 跟下面有关吗:
To expose nonremotable interfaces, a custom surrogate can inject a wrapper between the client and inproc object that can custom marshal into the client's apartment.
To implement nonstandard process/object lifetime semantics (such as shutting down idle servers or objects).
To spread the instances of an STA-only CLSID across multiple STA threads to increase concurrency for SMP machines. For an example of this, please see http://www.develop.com/dbox/com/surrogates/aptsur.htm.
To make the surrogate use hardwired security settings independent of what the administrator has configured using DCOMCNFG.EXE.
To play tricks on the client and swap in a different CLSID (or perhaps host machine) based on some dynamic state that your surrogate can monitor.
进程外接口通讯需要实现proxy/stub,如果仅是标准COM或者OLE接口(如IUnknown,IDispatch),可用其默认的proxy/stub程序,但如果你是自定义的接口(在idl中定义),必须得自己实现proxy/stub来保证你自定义接口的通讯.若接口成员函数的参数有指针或者结构参数,还需创建为实现Marshal和Unmarshal的proxy/stub代码。
解决方案4: 只有进程外组件才会用到proxy/stub,
进程外的每个接口函数都要proxy/stub
本地调用其它本地接口只需要在IDL中定义即可
远程过程调用时,需要象本机一样调用函数,就得用proxy stub,实现两端的通讯,还有参数的散列集
解决方案6:一般是为了提高调度的效率。