PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/CppCOMClient/RawAPI.h

#
C Header | 78 lines | 7 code | 6 blank | 65 comment | 0 complexity | 9ef4b8834155827eb0ca2066fd090e78 MD5 | raw file
  1. /****************************** Module Header ******************************\
  2. * Module Name: RawAPI.h
  3. * Project: CppCOMClient
  4. * Copyright (c) Microsoft Corporation.
  5. *
  6. * This file demontrates the use of C/C++ and the COM APIs to automate a server.
  7. * C/C++ Automation is much more difficult, but sometimes necessary to avoid
  8. * overhead with MFC, or problems with #import. Basically, you work with such
  9. * APIs as CoCreateInstance(), and COM interfaces such as IDispatch and IUnknown.
  10. *
  11. * References
  12. * http://support.microsoft.com/kb/216686
  13. * http://support.microsoft.com/kb/238393
  14. * http://support.microsoft.com/kb/216388
  15. *
  16. * This source is subject to the Microsoft Public License.
  17. * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  18. * All other rights reserved.
  19. *
  20. * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  21. * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  22. * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
  23. \***************************************************************************/
  24. #pragma once
  25. #pragma region Includes
  26. #include <ole2.h> // OLE2 Definitions
  27. #pragma endregion
  28. /*!
  29. * \brief
  30. * RawConsumeSTAComponent - Create and access a STA COM object by calling the
  31. * COM API directly from C++.
  32. *
  33. * \param lpParam
  34. * \returns
  35. * The prototype of a function that serves as the starting address for a
  36. * thread
  37. */
  38. DWORD WINAPI RawConsumeSTAComponent(LPVOID lpParam);
  39. /*!
  40. * \brief
  41. * Automation helper function.
  42. *
  43. * \param autoType
  44. * DISPATCH_PROPERTYGET || DISPATCH_PROPERTYPUT || DISPATCH_PROPERTYPUTREF
  45. * || DISPATCH_METHOD
  46. *
  47. * \param pvResult
  48. * Holds the return value in a VARIANT
  49. *
  50. * \param pDisp
  51. * The IDispatch interface
  52. *
  53. * \param ptName
  54. * The property/method name exposed by the interface
  55. *
  56. * \param cArgs
  57. * The count of the arguments
  58. *
  59. * \returns
  60. * HRESULT
  61. *
  62. * The AutoWrap() function simplifies most of the low-level details involved
  63. * with using IDispatch directly. Feel free to use it in your own
  64. * implementations. One caveat is that if you pass multiple parameters, they
  65. * need to be passed in reverse-order.
  66. *
  67. * \example
  68. * AutoWrap(
  69. * DISPATCH_METHOD, NULL, pDisp, L"call", 3, parm[2], parm[1], parm[0]);
  70. */
  71. HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp,
  72. LPOLESTR ptName, int cArgs...);