PageRenderTime 27ms CodeModel.GetById 24ms app.highlight 1ms RepoModel.GetById 1ms 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
25#pragma once
26
27#pragma region Includes
28#include <ole2.h> // OLE2 Definitions
29#pragma endregion
30
31
32/*!
33 * \brief
34 * RawConsumeSTAComponent - Create and access a STA COM object by calling the 
35 * COM API directly from C++.
36 * 
37 * \param lpParam
38 * \returns
39 * The prototype of a function that serves as the starting address for a 
40 * thread
41 */
42DWORD WINAPI RawConsumeSTAComponent(LPVOID lpParam);
43
44
45/*!
46 * \brief
47 * Automation helper function.
48 * 
49 * \param autoType
50 * DISPATCH_PROPERTYGET || DISPATCH_PROPERTYPUT || DISPATCH_PROPERTYPUTREF
51 * || DISPATCH_METHOD
52 * 
53 * \param pvResult
54 * Holds the return value in a VARIANT
55 * 
56 * \param pDisp
57 * The IDispatch interface
58 *
59 * \param ptName
60 * The property/method name exposed by the interface
61 * 
62 * \param cArgs
63 * The count of the arguments
64 * 
65 * \returns
66 * HRESULT
67 * 
68 * The AutoWrap() function simplifies most of the low-level details involved 
69 * with using IDispatch directly. Feel free to use it in your own 
70 * implementations. One caveat is that if you pass multiple parameters, they 
71 * need to be passed in reverse-order.
72 * 
73 * \example
74 * AutoWrap(
75 *     DISPATCH_METHOD, NULL, pDisp, L"call", 3, parm[2], parm[1], parm[0]);
76 */
77HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp,
78				 LPOLESTR ptName, int cArgs...);