PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/CppCOMClient/ImportDirective.h

#
C Header | 61 lines | 5 code | 4 blank | 52 comment | 0 complexity | bf8431a72e79217a6d93c90e14f3c117 MD5 | raw file
  1. /****************************** Module Header ******************************\
  2. * Module Name: ImportDirective.h
  3. * Project: CppCOMClient
  4. * Copyright (c) Microsoft Corporation.
  5. *
  6. * #import (http://msdn.microsoft.com/en-us/library/8etzzkb6.aspx), a new
  7. * directive that became available with Visual C++ 5.0, creates VC++ "smart
  8. * pointers" from a specified type library. It is very powerful, but often not
  9. * recommended because of reference-counting problems that typically occur when
  10. * used with the Microsoft Office applications. Unlike the direct API approach
  11. * in RawAPI.h/cpp, smart pointers enable us to benefit from the type info to
  12. * early/late bind the object. #import takes care of adding the messy guids to
  13. * the project and the COM APIs are encapsulated in custom classes that the
  14. * #import directive generates.
  15. *
  16. * The differences between early binding and late binding via smart pointers:
  17. *
  18. * Smart pointers make creating an object that supports early binding easy, so
  19. * does it make creating a late bound object. The only difference between early
  20. * binding and late binding via smart pointer is the .tlh and .tli files
  21. * generated by the #import directive. If the target object supports early
  22. * binding, the .tlh and .tli files will make use of the custom interface (not
  23. * IDispatch) to call the target property/method directly. If the target COM
  24. * object only support late binding, the smart pointer takes care of converting
  25. * your method calls into GetIDsOfNames()s and Invoke()s of the IDispatch
  26. * interface.
  27. *
  28. * References
  29. * http://support.microsoft.com/kb/169496
  30. *
  31. * This source is subject to the Microsoft Public License.
  32. * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  33. * All other rights reserved.
  34. *
  35. * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  36. * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  37. * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
  38. \***************************************************************************/
  39. #pragma once
  40. #pragma region Includes
  41. #include <ole2.h> // OLE2 Definitions
  42. #pragma endregion
  43. /*!
  44. * \brief
  45. * ImportCSharpComponent - Create and access a STA COM object written in C#
  46. * by using the smart pointer class and the #import compiler directive.
  47. *
  48. * \param lpParam
  49. * \returns
  50. * The prototype of a function that serves as the starting address for a
  51. * thread
  52. *
  53. * \remarks
  54. * In ImportDirective.cpp, the differences between #import-ing a native COM
  55. * object and #import-ing a .NET (C#) COM object are highlighted.
  56. */
  57. DWORD WINAPI ImportCSharpComponent(LPVOID lpParam);