MyAbc.cpp
Upload User: weisheen
Upload Date: 2022-07-09
Package Size: 19390k
Code Size: 1k
Development Platform:

Visual C++

  1. // MyAbc.cpp : Implementation of CMyAbc
  2. #include "stdafx.h"
  3. #include "DemoError.h"
  4. #include "MyAbc.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CMyAbc
  7. //(自动生成的)支持异常的接口函数
  8. STDMETHODIMP CMyAbc::InterfaceSupportsErrorInfo(REFIID riid)
  9. {
  10. static const IID* arr[] = 
  11. {
  12. &IID_IMyAbc
  13. };
  14. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  15. {
  16. if (InlineIsEqualGUID(*arr[i],riid))
  17. return S_OK;
  18. }
  19. return S_FALSE;
  20. }
  21. STDMETHODIMP CMyAbc::div(int a, int b, int *c)
  22. {
  23. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  24. // TODO: Add your implementation code here
  25. if(b==0)
  26. {
  27. CString str("b can not be zero!");
  28. this->Error(str.AllocSysString());//错误异常提示
  29. return S_FALSE;
  30. }
  31. else
  32. {
  33. *c=a/b;
  34. return S_OK;
  35. }
  36. }