MyAbc.cpp
上传用户:weisheen
上传日期:2022-07-09
资源大小:19390k
文件大小:1k
- // MyAbc.cpp : Implementation of CMyAbc
- #include "stdafx.h"
- #include "DispCallBack.h"
- #include "MyAbc.h"
- /////////////////////////////////////////////////////////////////////////////
- // CMyAbc
- STDMETHODIMP CMyAbc::SetLog(IDispatch *mylog)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- // TODO: Add your implementation code here
- this->pMytools=mylog;
- return S_OK;
- }
- STDMETHODIMP CMyAbc::add(int a, int b, int *c)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- // TODO: Add your implementation code here
- *c=a+b;
- if(this->pMytools!=NULL)
- {
- long id=1;
- //回调方法id;
- DISPID methodid=(DISPID)id;
- //回调方法参数;
- VARIANT paras[1];
- paras[0].vt=VT_BSTR;
- char buffer[20];
- sprintf(buffer,"%d",*c);
- CString str(buffer);
- paras[0].bstrVal=str.AllocSysString();
- DISPPARAMS disp;
- disp.cArgs=1;
- disp.rgvarg=paras;
- disp.cNamedArgs=0;
- disp.rgdispidNamedArgs=NULL;
- //输出参数;
- VARIANT vout;
- EXCEPINFO ex;
- UINT result=0;
- this->pMytools->Invoke(methodid,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,
- &disp,&vout,&ex,&result);
- }
- return S_OK;
- }