MyAbc.cpp
上传用户:weisheen
上传日期:2022-07-09
资源大小:19390k
文件大小:1k
- // MyAbc.cpp : Implementation of CMyAbc
- #include "stdafx.h"
- #include "DemoError.h"
- #include "MyAbc.h"
- /////////////////////////////////////////////////////////////////////////////
- // CMyAbc
- STDMETHODIMP CMyAbc::InterfaceSupportsErrorInfo(REFIID riid)
- {
- static const IID* arr[] =
- {
- &IID_IMyAbc//支持异常的接口ID
- };
- for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
- {
- if (InlineIsEqualGUID(*arr[i],riid))
- return S_OK;
- }
- return S_FALSE;
- }
- STDMETHODIMP CMyAbc::div(int a, int b, int *c)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- // TODO: Add your implementation code here
- if(b==0)
- {
- CString str("b can not be zero!");
- this->Error(str.AllocSysString());
- return S_FALSE;
- }
- else
- {
- *c=a/b;
- return S_OK;
- }
- }