欢迎来到天天文库
浏览记录
ID:57695307
大小:66.00 KB
页数:12页
时间:2020-09-01
《ATL下进程外COM框架实例.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、///Client///Clientclient.cpp///Proxy///ProxyServer.idl///ProxyServerps.def///Server///ServerATLDevGuide.h///ServerServer.cpp///ServerServer.def///ServerServer.h///ServerServer.rc///ServerMath.cpp///ServerMath.h///ServerMath.rgs///Serverresource.h///ServerStdA
2、fx.cpp///ServerStdAfx.h---------------------------------------///Client///Client/client.cpp////Client.cpp//#include#include#include#include#include"Server_i.c"#include"Server.h"usingnamespacestd;intmain(intargc,char*argv[]){cout<
3、<"InitializingCOM"<4、<<"Failedtocreateserverinstance.HR="<Multiply(100,8,&result);cout<<"100*8is"<Subtract(1000,333,&result);cout<<"1000-333is"<5、*pAdvMath=NULL;hr=pMath->QueryInterface(IID_IAdvancedMath,(LPVOID*)&pAdvMath);if(FAILED(hr)){cout<<"QueryInterface()forIAdvancedMathfailed"<Release();CoUninitialize();return-1;}pAdvMath->Factorial(10,&result);cout<<"10!is"<Fibonacci(106、,&result);cout<<"TheFibonacciof10is"<Release();cout<<"ReleasingIAdvancedMathinterface"<Release();cout<<"ShutingdownCOM"<7、sourceforServer.dll////ThisfilewillbeprocessedbytheMIDLtoolto//producethetypelibrary(Server.tlb)andmarshallingcode.import"oaidl.idl";import"ocidl.idl";[object,uuid(8812699C-1CC8-11D1-883A-444553540000),helpstring("IMathInterface"),pointer_default(unique)]interfaceIMath:IU8、nknown{[helpstring("methodAdd")]HRESULTAdd([in]longlOp1,[in]longlOp2,[out,retval]long*plResult);
4、<<"Failedtocreateserverinstance.HR="<
5、*pAdvMath=NULL;hr=pMath->QueryInterface(IID_IAdvancedMath,(LPVOID*)&pAdvMath);if(FAILED(hr)){cout<<"QueryInterface()forIAdvancedMathfailed"<Release();CoUninitialize();return-1;}pAdvMath->Factorial(10,&result);cout<<"10!is"<Fibonacci(10
6、,&result);cout<<"TheFibonacciof10is"<Release();cout<<"ReleasingIAdvancedMathinterface"<Release();cout<<"ShutingdownCOM"<7、sourceforServer.dll////ThisfilewillbeprocessedbytheMIDLtoolto//producethetypelibrary(Server.tlb)andmarshallingcode.import"oaidl.idl";import"ocidl.idl";[object,uuid(8812699C-1CC8-11D1-883A-444553540000),helpstring("IMathInterface"),pointer_default(unique)]interfaceIMath:IU8、nknown{[helpstring("methodAdd")]HRESULTAdd([in]longlOp1,[in]longlOp2,[out,retval]long*plResult);
7、sourceforServer.dll////ThisfilewillbeprocessedbytheMIDLtoolto//producethetypelibrary(Server.tlb)andmarshallingcode.import"oaidl.idl";import"ocidl.idl";[object,uuid(8812699C-1CC8-11D1-883A-444553540000),helpstring("IMathInterface"),pointer_default(unique)]interfaceIMath:IU
8、nknown{[helpstring("methodAdd")]HRESULTAdd([in]longlOp1,[in]longlOp2,[out,retval]long*plResult);
此文档下载收益归作者所有