compobj.h
来自「用于查询PC机上的USB端口是否有设备挂接上」· C头文件 代码 · 共 979 行 · 第 1/3 页
H
979 行
DWORD dwHighDateTime;
} FILETIME;
#endif
#endif
#ifdef WIN32
#define HTASK DWORD
#endif
#include "scode.h"
// *********************** Compobj errors **********************************
#define CO_E_NOTINITIALIZED (CO_E_FIRST + 0x0)
// CoInitialize has not been called and must be
#define CO_E_ALREADYINITIALIZED (CO_E_FIRST + 0x1)
// CoInitialize has already been called and cannot be called again (temporary)
#define CO_E_CANTDETERMINECLASS (CO_E_FIRST + 0x2)
// can't determine clsid (e.g., extension not in reg.dat)
#define CO_E_CLASSSTRING (CO_E_FIRST + 0x3)
// the string form of the clsid is invalid (including ole1 classes)
#define CO_E_IIDSTRING (CO_E_FIRST + 0x4)
// the string form of the iid is invalid
#define CO_E_APPNOTFOUND (CO_E_FIRST + 0x5)
// application not found
#define CO_E_APPSINGLEUSE (CO_E_FIRST + 0x6)
// application cannot be run more than once
#define CO_E_ERRORINAPP (CO_E_FIRST + 0x7)
// some error in the app program file
#define CO_E_DLLNOTFOUND (CO_E_FIRST + 0x8)
// dll not found
#define CO_E_ERRORINDLL (CO_E_FIRST + 0x9)
// some error in the dll file
#define CO_E_WRONGOSFORAPP (CO_E_FIRST + 0xa)
// app written for other version of OS or other OS altogether
#define CO_E_OBJNOTREG (CO_E_FIRST + 0xb)
// object is not registered
#define CO_E_OBJISREG (CO_E_FIRST + 0xc)
// object is already registered
#define CO_E_OBJNOTCONNECTED (CO_E_FIRST + 0xd)
// handler is not connected to server
#define CO_E_APPDIDNTREG (CO_E_FIRST + 0xe)
// app was launched, but didn't registered a class factory
// ********************* ClassObject errors ********************************
#define CLASS_E_NOAGGREGATION (CLASSFACTORY_E_FIRST + 0x0)
// class does not support aggregation (or class object is remote)
// *********************** Reg.dat errors **********************************
#define REGDB_E_READREGDB (REGDB_E_FIRST + 0x0)
// some error reading the registration database
#define REGDB_E_WRITEREGDB (REGDB_E_FIRST + 0x1)
// some error reading the registration database
#define REGDB_E_KEYMISSING (REGDB_E_FIRST + 0x2)
// some error reading the registration database
#define REGDB_E_INVALIDVALUE (REGDB_E_FIRST + 0x3)
// some error reading the registration database
#define REGDB_E_CLASSNOTREG (REGDB_E_FIRST + 0x4)
// some error reading the registration database
#define REGDB_E_IIDNOTREG (REGDB_E_FIRST + 0x5)
// some error reading the registration database
// *************************** RPC errors **********************************
#define RPC_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_RPC, 0x000)
// call was rejected by callee, either by MF::HandleIncomingCall or
#define RPC_E_CALL_REJECTED (RPC_E_FIRST + 0x1)
// call was canceld by call - returned by MessagePending
// this code only occurs if MessagePending return cancel
#define RPC_E_CALL_CANCELED (RPC_E_FIRST + 0x2)
// the caller is dispatching an intertask SendMessage call and
// can NOT call out via PostMessage
#define RPC_E_CANTPOST_INSENDCALL (RPC_E_FIRST + 0x3)
// the caller is dispatching an asynchronus call can NOT
// make an outgoing call on behalf of this call
#define RPC_E_CANTCALLOUT_INASYNCCALL (RPC_E_FIRST + 0x4)
// the caller is not in a state where an outgoing call can be made
// this is the case if the caller has an outstandig call and
// another incoming call was excepted by HIC; now the caller is
// not allowed to call out again
#define RPC_E_CANTCALLOUT_INEXTERNALCALL (RPC_E_FIRST + 0x5)
// the connection terminated or is in a bogus state
// and can not be used any more. Other connections
// are still valid.
#define RPC_E_CONNECTION_TERMINATED (RPC_E_FIRST + 0x6)
// the callee (server [not server application]) is not available
// and disappeared; all connections are invalid
#define RPC_E_SERVER_DIED (RPC_E_FIRST + 0x7)
// the caller (client ) disappeared while the callee (server) was
// processing a call
#define RPC_E_CLIENT_DIED (RPC_E_FIRST + 0x8)
// the date paket with the marshalled parameter data is
// incorrect
#define RPC_E_INVALID_DATAPACKET (RPC_E_FIRST + 0x9)
// the call was not transmitted properly; the message queue
// was full and was not emptied after yielding
#define RPC_E_CANTTRANSMIT_CALL (RPC_E_FIRST + 0xa)
// the client (caller) can not marshall the parameter data
// or unmarshall the return data - low memory etc.
#define RPC_E_CLIENT_CANTMARSHAL_DATA (RPC_E_FIRST + 0xb)
#define RPC_E_CLIENT_CANTUNMARSHAL_DATA (RPC_E_FIRST + 0xc)
// the server (caller) can not unmarshall the parameter data
// or marshall the return data - low memory
#define RPC_E_SERVER_CANTMARSHAL_DATA (RPC_E_FIRST + 0xd)
#define RPC_E_SERVER_CANTUNMARSHAL_DATA (RPC_E_FIRST + 0xe)
// received data are invalid; can be server or
// client data
#define RPC_E_INVALID_DATA (RPC_E_FIRST + 0xf)
// a particular parameter is invalid and can not be un/marshalled
#define RPC_E_INVALID_PARAMETER (RPC_E_FIRST + 0x10)
// a internal error occured
#define RPC_E_UNEXPECTED (RPC_E_FIRST + 0xFFFF)
/****** Globally Unique Ids *************************************************/
#ifdef __cplusplus
struct FAR GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data4[8];
BOOL operator==(const GUID& iidOther) const
#ifdef WIN32
{ return !memcmp(&Data1,&iidOther.Data1,sizeof(GUID)); }
#else
{ return !_fmemcmp(&Data1,&iidOther.Data1,sizeof(GUID)); }
#endif
BOOL operator!=(const GUID& iidOther) const
{ return !((*this) == iidOther); }
};
#else
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID {
ULONG Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
#endif // !defined(GUID_DEFINED)
#endif
typedef GUID FAR* LPGUID;
// macros to define byte pattern for a GUID.
// Example: DEFINE_GUID(GUID_XXX, a, b, c, ...);
//
// Each dll/exe must initialize the GUIDs once. This is done in one of
// two ways. If you are not using precompiled headers for the file(s) which
// initializes the GUIDs, define INITGUID before including compobj.h. This
// is how OLE builds the initialized versions of the GUIDs which are included
// in ole2.lib. The GUIDs in ole2.lib are all defined in the same text
// segment GUID_TEXT.
//
// The alternative (which some versions of the compiler don't handle properly;
// they wind up with the initialized GUIDs in a data, not a text segment),
// is to use a precompiled version of compobj.h and then include initguid.h
// after compobj.h followed by one or more of the guid defintion files.
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
EXTERN_C const GUID CDECL FAR name
#ifdef INITGUID
#include "initguid.h"
#endif
#define DEFINE_OLEGUID(name, l, w1, w2) \
DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
// Interface ID are just a kind of GUID
typedef GUID IID;
typedef IID FAR* LPIID;
#define IID_NULL GUID_NULL
#define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
// Class ID are just a kind of GUID
typedef GUID CLSID;
typedef CLSID FAR* LPCLSID;
#define CLSID_NULL GUID_NULL
#define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
#if defined(__cplusplus)
#define REFGUID const GUID FAR&
#define REFIID const IID FAR&
#define REFCLSID const CLSID FAR&
#else
#define REFGUID const GUID FAR* const
#define REFIID const IID FAR* const
#define REFCLSID const CLSID FAR* const
#endif
#ifndef INITGUID
#include "coguid.h"
#endif
/****** Other value types ***************************************************/
// memory context values; passed to CoGetMalloc
typedef enum tagMEMCTX
{
MEMCTX_TASK = 1, // task (private) memory
MEMCTX_SHARED = 2, // shared memory (between processes)
#ifdef _MAC
MEMCTX_MACSYSTEM = 3, // on the mac, the system heap
#endif
// these are mostly for internal use...
MEMCTX_UNKNOWN = -1, // unknown context (when asked about it)
MEMCTX_SAME = -2, // same context (as some other pointer)
} MEMCTX;
// class context: used to determine what scope and kind of class object to use
// NOTE: this is a bitwise enum
typedef enum tagCLSCTX
{
CLSCTX_INPROC_SERVER = 1, // server dll (runs in same process as caller)
CLSCTX_INPROC_HANDLER = 2, // handler dll (runs in same process as caller)
CLSCTX_LOCAL_SERVER = 4 // server exe (runs on same machine; diff proc)
} CLSCTX;
#define CLSCTX_ALL (CLSCTX_INPROC_SERVER| \
CLSCTX_INPROC_HANDLER| \
CLSCTX_LOCAL_SERVER)
#define CLSCTX_INPROC (CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER)
#define CLSCTX_SERVER (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER)
// class registration flags; passed to CoRegisterClassObject
typedef enum tagREGCLS
{
REGCLS_SINGLEUSE = 0, // class object only generates one instance
REGCLS_MULTIPLEUSE = 1 // same class object genereates multiple inst.
} REGCLS;
// interface marshaling definitions
#define MARSHALINTERFACE_MIN 40 // minimum number of bytes for interface marshl
// marshaling flags; passed to CoMarshalInterface
typedef enum tagMSHLFLAGS
{
MSHLFLAGS_NORMAL = 0, // normal marshaling via proxy/stub
MSHLFLAGS_TABLESTRONG = 1, // keep object alive; must explicitly release
MSHLFLAGS_TABLEWEAK = 2 // doesn't hold object alive; still must release
} MSHLFLAGS;
// marshal context: determines the destination context of the marshal operation
typedef enum tagMSHCTX
{
MSHCTX_LOCAL = 0, // unmarshal context is local (eg.shared memory)
MSHCTX_NOSHAREDMEM = 1, // unmarshal context has no shared memory access
} MSHCTX;
// call type used by IMessageFilter::HandleIncommingMessage
typedef enum tagCALLTYPE
{
CALLTYPE_TOPLEVEL = 1, // toplevel call - no outgoing call
CALLTYPE_NESTED = 2, // callback on behalf of previous outgoing call - should always handle
CALLTYPE_ASYNC = 3, // aysnchronous call - can NOT be rejected
CALLTYPE_TOPLEVEL_CALLPENDING = 4, // new toplevel call with new LID
CALLTYPE_ASYNC_CALLPENDING = 5 // async call - can NOT be rejected
} CALLTYPE;
// status of server call - returned by IMessageFilter::HandleIncommingCall
// and passed to IMessageFilter::RetryRejectedCall
typedef enum tagSERVERCALL
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?