代码如下: OleInitialize(NULL); pResults.pIID= &IID_ITOperator; pResults.pItf= NULL; pResults.hr =0; COSERVERINFO pServerInfo; pServerInfo.dwReserved1=0; pServerInfo.pwszName = WideString("fish"); pServerInfo.dwReserved2=0; pServerInfo.pAuthInfo=NULL; CoCreateInstanceEx( CLSID_TOperator, //CLSID of the object to be created NULL, //If part of an aggregate, the // controlling IUnknown CLSCTX_SERVER , //CLSCTX values &pServerInfo, //Machine on which the object is to // be instantiated 1, //Number of MULTI_QI structures in // pResults &pResults //Array of MULTI_QI structures ); if(pResults.pItf == NULL) MessageBox(NULL,"error,m_interface not obtain!","error",MB_OK);
OleInitialize(NULL); pResults.pIID= &IID_ITOperator;
pResults.pItf= NULL;
pResults.hr =0; COSERVERINFO pServerInfo;
pServerInfo.dwReserved1=0;
pServerInfo.pwszName = WideString("fish");
pServerInfo.dwReserved2=0;
pServerInfo.pAuthInfo=NULL;
CoCreateInstanceEx(
CLSID_TOperator, //CLSID of the object to be created
NULL, //If part of an aggregate, the
// controlling IUnknown
CLSCTX_SERVER , //CLSCTX values
&pServerInfo, //Machine on which the object is to
// be instantiated
1, //Number of MULTI_QI structures in
// pResults
&pResults //Array of MULTI_QI structures
); if(pResults.pItf == NULL)
MessageBox(NULL,"error,m_interface not obtain!","error",MB_OK);
//到这指针都不为空,但调用出错!
((ITOperator*) pResults.pItf)-> method();
OleUninitialize();