COMDemo.h
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:2k
源码类别:

C#编程

开发平台:

Others

  1. // COMDemo.h : Declaration of the CCOMDemo
  2. #pragma once
  3. #include "resource.h"       // main symbols
  4. // _ICompletedEvents
  5. [
  6. dispinterface,
  7. uuid("B2CBBCD3-2993-4148-8EF4-356EACFD834B"),
  8.     custom(0F21F359-AB84-41e8-9A78-36D110E6D2F9, 
  9.      "Wrox.ProCSharp.COMInterop.Server.ICompletedEvents"),
  10. helpstring("_ICompletedEvents Interface")
  11. ]
  12. __interface _ICompletedEvents
  13. {
  14. [id(1)] void Completed(void);
  15. };
  16. // IMath
  17. [
  18. object,
  19. uuid("2158751B-896E-461d-9012-EF1680BE0628"),
  20. dual,
  21. helpstring("IMath Interface"),
  22. pointer_default(unique),
  23.     custom(0F21F359-AB84-41e8-9A78-36D110E6D2F9, 
  24.      "Wrox.ProCSharp.COMInterop.Server.IMath")
  25. ]
  26. __interface IMath : IDispatch
  27. {
  28. [id(1)] HRESULT Add([in] LONG val1, [in] LONG val2, [out, retval] LONG* result);
  29. [id(2)] HRESULT Sub([in] LONG val1, [in] LONG val2, [out, retval] LONG* result);
  30. };
  31. // ICOMDemo
  32. [
  33. object,
  34. uuid("015ED275-3DE6-4716-A6FA-4EBC71E4A8EA"),
  35. dual, helpstring("ICOMDemo Interface"),
  36. pointer_default(unique),
  37.     custom(0F21F359-AB84-41e8-9A78-36D110E6D2F9, 
  38.      "Wrox.ProCSharp.COMInterop.Server.IWelcome")
  39. ]
  40. __interface IWelcome : IDispatch
  41. {
  42. [id(1)] HRESULT Greeting([in] BSTR name, [out, retval] BSTR* message);
  43. };
  44. // CCOMDemo
  45. [
  46. coclass,
  47. threading("apartment"),
  48. vi_progid("COMServer.COMDemo"),
  49. progid("COMServer.COMDemo.1"),
  50. version(1.0),
  51.     custom(0F21F359-AB84-41e8-9A78-36D110E6D2F9, 
  52.      "Wrox.ProCSharp.COMInterop.Server.COMDemo"),
  53. uuid("2388AAA8-AD72-4022-948D-555316F708E8"),
  54. event_source("com"),
  55. helpstring("COMDemo Class")
  56. ]
  57. class ATL_NO_VTABLE CCOMDemo : 
  58. public IWelcome, public IMath
  59. {
  60. public:
  61. CCOMDemo()
  62. {
  63. }
  64. __event __interface _ICompletedEvents;
  65. void FireCompleted()
  66. {
  67. __raise Completed();
  68. }
  69. DECLARE_PROTECT_FINAL_CONSTRUCT()
  70. HRESULT FinalConstruct()
  71. {
  72. return S_OK;
  73. }
  74. void FinalRelease() 
  75. {
  76. }
  77. public:
  78. STDMETHOD(Greeting)(BSTR name, BSTR* message);
  79. STDMETHOD(Add)(LONG val1, LONG val2, LONG* result);
  80. STDMETHOD(Sub)(LONG val1, LONG val2, LONG* result);
  81. };