compobj.h
来自「用于查询PC机上的USB端口是否有设备挂接上」· C头文件 代码 · 共 979 行 · 第 1/3 页
H
979 行
// compobj.h - component object model definitions
#if !defined( _COMPOBJ_H_ )
#define _COMPOBJ_H_
/****** Linkage Definitions *************************************************/
/*
* These are macros for declaring methods/functions. They exist so that
* control over the use of keywords (CDECL, PASCAL, __export,
* extern "C") resides in one place, and because this is the least
* intrusive way of writing function declarations that do not have
* to be modified in order to port to the Mac.
*
* The macros without the trailing underscore are for functions/methods
* which a return value of type HRESULT; this is by far the most common
* case in OLE. The macros with a trailing underscore take a return
* type as a parameter.
*
* WARNING: STDAPI is hard coded into the LPFNGETCLASSOBJECT typedef below.
*/
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C extern
#endif
#ifdef _MAC
#define STDMETHODCALLTYPE
#define STDAPICALLTYPE pascal
#define STDAPI EXTERN_C STDAPICALLTYPE HRESULT
#define STDAPI_(type) EXTERN_C STDAPICALLTYPE type
#else // !_MAC
#ifdef WIN32
#define STDMETHODCALLTYPE __export __cdecl
#define STDAPICALLTYPE __export __stdcall
#define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
#define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
#else
#define STDMETHODCALLTYPE __export FAR CDECL
#define STDAPICALLTYPE __export FAR PASCAL
#define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
#define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
#endif
#endif //!_MAC
#define STDMETHODIMP HRESULT STDMETHODCALLTYPE
#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
/****** Interface Declaration ***********************************************/
/*
* These are macros for declaring interfaces. They exist so that
* a single definition of the interface is simulataneously a proper
* declaration of the interface structures (C++ abstract classes)
* for both C and C++.
*
* DECLARE_INTERFACE(iface) is used to declare an interface that does
* not derive from a base interface.
* DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface
* that does derive from a base interface.
*
* By default if the source file has a .c extension the C version of
* the interface declaratations will be expanded; if it has a .cpp
* extension the C++ version will be expanded. if you want to force
* the C version expansion even though the source file has a .cpp
* extension, then define the macro "CINTERFACE".
* eg. cl -DCINTERFACE file.cpp
*
* Example Interface declaration:
*
* #undef INTERFACE
* #define INTERFACE IClassFactory
*
* DECLARE_INTERFACE_(IClassFactory, IUnknown)
* {
* // *** IUnknown methods ***
* STDMETHOD(QueryInterface) (THIS_
* REFIID riid,
* LPVOID FAR* ppvObj) PURE;
* STDMETHOD_(ULONG,AddRef) (THIS) PURE;
* STDMETHOD_(ULONG,Release) (THIS) PURE;
*
* // *** IClassFactory methods ***
* STDMETHOD(CreateInstance) (THIS_
* LPUNKNOWN pUnkOuter,
* REFIID riid,
* LPVOID FAR* ppvObject) PURE;
* };
*
* Example C++ expansion:
*
* struct FAR IClassFactory : public IUnknown
* {
* virtual HRESULT STDMETHODCALLTYPE QueryInterface(
* IID FAR& riid,
* LPVOID FAR* ppvObj) = 0;
* virtual HRESULT STDMETHODCALLTYPE AddRef(void) = 0;
* virtual HRESULT STDMETHODCALLTYPE Release(void) = 0;
* virtual HRESULT STDMETHODCALLTYPE CreateInstance(
* LPUNKNOWN pUnkOuter,
* IID FAR& riid,
* LPVOID FAR* ppvObject) = 0;
* };
*
* NOTE: Our documentation says '#define interface class' but we use
* 'struct' instead of 'class' to keep a lot of 'public:' lines
* out of the interfaces. The 'FAR' forces the 'this' pointers to
* be far, which is what we need.
*
* Example C expansion:
*
* typedef struct IClassFactory
* {
* const struct IClassFactoryVtbl FAR* lpVtbl;
* } IClassFactory;
*
* typedef struct IClassFactoryVtbl IClassFactoryVtbl;
*
* struct IClassFactoryVtbl
* {
* HRESULT (STDMETHODCALLTYPE * QueryInterface) (
* IClassFactory FAR* This,
* IID FAR* riid,
* LPVOID FAR* ppvObj) ;
* HRESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ;
* HRESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ;
* HRESULT (STDMETHODCALLTYPE * CreateInstance) (
* IClassFactory FAR* This,
* LPUNKNOWN pUnkOuter,
* IID FAR* riid,
* LPVOID FAR* ppvObject);
* HRESULT (STDMETHODCALLTYPE * LockServer) (
* IClassFactory FAR* This,
* BOOL fLock);
* };
*/
#if defined(__cplusplus) && !defined(CINTERFACE)
#ifdef __TURBOC__
#define interface struct huge
#else
#define interface struct FAR
#endif
#define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method
#define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
#define PURE = 0
#define THIS_
#define THIS void
#define DECLARE_INTERFACE(iface) interface iface
#define DECLARE_INTERFACE_(iface, baseiface) interface iface : public baseiface
#else
#define interface struct
#ifdef _MAC
#define STDMETHOD(method) long method##pad;\
HRESULT (STDMETHODCALLTYPE * method)
#define STDMETHOD_(type,method) long method##pad;\
type (STDMETHODCALLTYPE * method)
#else // _MAC
#define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE * method)
#define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
#endif // !_MAC
#define PURE
#define THIS_ INTERFACE FAR* This,
#define THIS INTERFACE FAR* This
#ifdef CONST_VTABLE
#define DECLARE_INTERFACE(iface) typedef interface iface { \
const struct iface##Vtbl FAR* lpVtbl; \
} iface; \
typedef const struct iface##Vtbl iface##Vtbl; \
const struct iface##Vtbl
#else
#define DECLARE_INTERFACE(iface) typedef interface iface { \
struct iface##Vtbl FAR* lpVtbl; \
} iface; \
typedef struct iface##Vtbl iface##Vtbl; \
struct iface##Vtbl
#endif
#define DECLARE_INTERFACE_(iface, baseiface) DECLARE_INTERFACE(iface)
#endif
/****** Additional basic types **********************************************/
#ifndef FARSTRUCT
#ifdef __cplusplus
#define FARSTRUCT FAR
#else
#define FARSTRUCT
#endif // __cplusplus
#endif // FARSTRUCT
#ifndef WINAPI /* If not included with 3.1 headers... */
#ifdef WIN32
#define FAR
#define PASCAL __stdcall
#define CDECL
#else
#define FAR _far
#define PASCAL _pascal
#define CDECL _cdecl
#endif
#define VOID void
#define WINAPI FAR PASCAL
#define CALLBACK FAR PASCAL
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned int UINT;
typedef long LONG;
typedef unsigned long DWORD;
typedef UINT WPARAM;
typedef LONG LPARAM;
typedef LONG LRESULT;
typedef unsigned int HANDLE;
#define DECLARE_HANDLE(name) typedef UINT name
DECLARE_HANDLE(HMODULE);
DECLARE_HANDLE(HINSTANCE);
DECLARE_HANDLE(HLOCAL);
DECLARE_HANDLE(HGLOBAL);
DECLARE_HANDLE(HDC);
DECLARE_HANDLE(HRGN);
DECLARE_HANDLE(HWND);
DECLARE_HANDLE(HMENU);
DECLARE_HANDLE(HACCEL);
DECLARE_HANDLE(HTASK);
#ifndef NULL
#define NULL 0
#endif
typedef void FAR * LPVOID;
typedef WORD FAR * LPWORD;
typedef DWORD FAR * LPDWORD;
typedef char FAR* LPSTR;
typedef const char FAR* LPCSTR;
typedef void FAR* LPLOGPALETTE;
typedef void FAR* LPMSG;
//typedef struct tagMSG FAR *LPMSG;
typedef HANDLE FAR *LPHANDLE;
typedef struct tagRECT FAR *LPRECT;
typedef struct FARSTRUCT tagSIZE
{
int cx;
int cy;
} SIZE;
typedef SIZE* PSIZE;
#endif /* WINAPI */
typedef short SHORT;
typedef unsigned short USHORT;
typedef DWORD ULONG;
#ifndef HUGEP
#ifdef WIN32
#define HUGEP
#else
#define HUGEP __huge
#endif // WIN32
#endif // HUGEP
typedef WORD WCHAR;
#ifndef WIN32
typedef struct FARSTRUCT _LARGE_INTEGER {
DWORD LowPart;
LONG HighPart;
} LARGE_INTEGER, *PLARGE_INTEGER;
#endif
#define LISet32(li, v) ((li).HighPart = ((LONG)(v)) < 0 ? -1 : 0, (li).LowPart = (v))
#ifndef WIN32
typedef struct FARSTRUCT _ULARGE_INTEGER {
DWORD LowPart;
DWORD HighPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;
#endif
#define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v))
#ifndef _WINDOWS_
#ifndef _FILETIME_
#define _FILETIME_
typedef struct FARSTRUCT tagFILETIME
{
DWORD dwLowDateTime;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?