' ########################################################################################
' Microsoft Windows
' File: ObjBase.inc
' Contents: Component object model defintions
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_ObjBase_PBI)
#DEFINE PBX_ObjBase_PBI
%EQUATE `OBJBASE_INC = 1
#INCLUDE ONCE "Legacy/System/WTypes.inc"
#INCLUDE ONCE "Legacy/COM/Unknwn.inc"
#INCLUDE ONCE "Legacy/COM/ObjIdl.inc"
#INCLUDE ONCE "Legacy/UI/Guiddef.inc"
#IF NOT %DEF(%INITGUID)
#INCLUDE ONCE "Legacy/UI/CGuid.inc"
#ENDIF
'/****** 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);
' * };
' */
'/****** Additional basic types **********************************************/
'#include <stdlib.h>
'#define LISet32(li, v) ((li).HighPart = ((LONG) (v)) < 0 ? -1 : 0, (li).LowPart = (v))
'#define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v))
%EQUATE `CLSCTX_INPROC = %CLSCTX_INPROC_SERVER OR %CLSCTX_INPROC_HANDLER
#IF %DEF(%WIN32_DCOM) ' // DCOM
%EQUATE `CLSCTX_ALL = %CLSCTX_INPROC_SERVER OR %CLSCTX_INPROC_HANDLER OR %CLSCTX_LOCAL_SERVER OR %CLSCTX_REMOTE_SERVER
%EQUATE `CLSCTX_SERVER = %CLSCTX_INPROC_SERVER OR %CLSCTX_LOCAL_SERVER OR %CLSCTX_REMOTE_SERVER
#ELSE
%EQUATE `CLSCTX_ALL = %CLSCTX_INPROC_SERVER OR %CLSCTX_INPROC_HANDLER OR %CLSCTX_LOCAL_SERVER
%EQUATE `CLSCTX_SERVER = %CLSCTX_INPROC_SERVER OR %CLSCTX_LOCAL_SERVER
#ENDIF ' // DCOM
'// class registration flags; passed to CoRegisterClassObject
' REGCLS enum
%EQUATE `REGCLS_SINGLEUSE = 0 ' // class object only generates one instance
%EQUATE `REGCLS_MULTIPLEUSE = 1 ' // same class object genereates multiple inst.
 ' // and local automatically goes into inproc tbl.
%EQUATE `REGCLS_MULTI_SEPARATE = 2 ' // multiple use, but separate control over each context.
%EQUATE `REGCLS_SUSPENDED = 4 ' // register is as suspended, will be activated
 ' // when app calls CoResumeClassObjects
%EQUATE `REGCLS_SURROGATE = 8 ' // must be used when a surrogate process
 ' // is registering a class object that will be
 ' // loaded in the surrogate
'// interface marshaling definitions
%EQUATE `MARSHALINTERFACE_MIN = 500 ' // minimum number of bytes for interface marshl
'//
'// Common typedefs for paramaters used in Storage API's, gleamed from storage.h
'// Also contains Storage error codes, which should be moved into the storage
'// idl files.
'//
%EQUATE `CWCSTORAGENAME = 32
'/* Storage instantiation modes */
%EQUATE `STGM_DIRECT = &H00000000
%EQUATE `STGM_TRANSACTED = &H00010000
%EQUATE `STGM_DIRECT_SWMR = &H00400000
%EQUATE `STGM_SIMPLE = &H08000000
%EQUATE `STGM_READ = &H00000000
%EQUATE `STGM_WRITE = &H00000001
%EQUATE `STGM_READWRITE = &H00000002
%EQUATE `STGM_SHARE_DENY_NONE = &H00000040
%EQUATE `STGM_SHARE_DENY_READ = &H00000030
%EQUATE `STGM_SHARE_DENY_WRITE = &H00000020
%EQUATE `STGM_SHARE_EXCLUSIVE = &H00000010
%EQUATE `STGM_PRIORITY = &H00040000
%EQUATE `STGM_DELETEONRELEASE = &H04000000
'#if (WINVER >= 400)
%EQUATE `STGM_NOSCRATCH = &H00100000
'#endif /* WINVER */
%EQUATE `STGM_CREATE = &H00001000
%EQUATE `STGM_CONVERT = &H00020000
%EQUATE `STGM_FAILIFTHERE = &H00000000
%EQUATE `STGM_NOSNAPSHOT = &H00200000
'#if (_WIN32_WINNT >= 0x0500)
%EQUATE `STGM_DIRECT_SWMR = &H00400000
'#endif
'/* flags for internet asyncronous and layout docfile */
%EQUATE `ASYNC_MODE_COMPATIBILITY = &H00000001
%EQUATE `ASYNC_MODE_DEFAULT = &H00000000
%EQUATE `STGTY_REPEAT = &H00000100
%EQUATE `STG_TOEND = &HFFFFFFFF
%EQUATE `STG_LAYOUT_SEQUENTIAL = &H00000000
%EQUATE `STG_LAYOUT_INTERLEAVED = &H00000001
%EQUATE `STGFMT_STORAGE = 0
%EQUATE `STGFMT_NATIVE = 1
%EQUATE `STGFMT_FILE = 3
%EQUATE `STGFMT_ANY = 4
%EQUATE `STGFMT_DOCFILE = 5
'// This is a legacy define to allow old component to builds
%EQUATE `STGFMT_DOCUMENT = 0
'// COM initialization flags; passed to CoInitialize.
' COINIT enum
%EQUATE `COINIT_APARTMENTTHREADED = &H2
#IF %DEF(%WIN32_DCOM) ' // DCOM
' // These constants are only valid on Windows NT 4.0
%EQUATE `COINIT_MULTITHREADED = &H0 ' // OLE calls objects on any thread.
%EQUATE `COINIT_DISABLE_OLE1DDE = &H4 ' // Don't use DDE for Ole1 support.
%EQUATE `COINIT_SPEED_OVER_MEMORY = &H8 ' // Trade memory for speed.
#ENDIF ' // DCOM
'/****** STD Object API Prototypes *****************************************/
DECLARE FUNCTION CoBuildVersion LIB "ole32.dll" ALIAS "CoBuildVersion" ( ) AS QUAD
'/* init/uninit */
DECLARE FUNCTION CoInitialize LIB "ole32.dll" ALIAS "CoInitialize" ( OPTIONAL BYVAL pvReserved AS QUAD ) AS LONG
DECLARE SUB CoUninitialize LIB "ole32.dll" ALIAS "CoUninitialize" () ' void
DECLARE FUNCTION CoGetMalloc LIB "ole32.dll" ALIAS "CoGetMalloc" ( BYVAL dwMemContext AS QUAD , BYREF ppMalloc AS IMalloc ) AS LONG
DECLARE FUNCTION CoGetCurrentProcess LIB "ole32.dll" ALIAS "CoGetCurrentProcess" ( ) AS QUAD
DECLARE FUNCTION CoRegisterMallocSpy LIB "ole32.dll" ALIAS "CoRegisterMallocSpy" ( BYVAL pMallocSpy AS IMallocSpy
 ) AS LONG
DECLARE FUNCTION CoRevokeMallocSpy LIB "ole32.dll" ALIAS "CoRevokeMallocSpy" ( ) AS LONG
' This function is obsolete. Refer to CoGetMalloc.
'WINOLEAPI CoCreateStandardMalloc(IN DWORD memctx, OUT IMalloc FAR* FAR* ppMalloc);
'#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
DECLARE FUNCTION CoInitializeEx LIB "ole32.dll" ALIAS "CoInitializeEx" ( BYVAL pvReserved AS QUAD , BYVAL dwCoInit AS QUAD ) AS LONG
DECLARE FUNCTION CoGetCallerTID LIB "ole32.dll" ALIAS "CoGetCallerTID" ( BYREF lpdwTID AS QUAD
 ) AS LONG
DECLARE FUNCTION CoGetCurrentLogicalThreadId LIB "ole32.dll" ALIAS "CoGetCurrentLogicalThreadId" ( BYREF pguid AS GUID
 ) AS LONG
'#endif // DCOM
'#if (_WIN32_WINNT >= 0x0501)
DECLARE FUNCTION CoRegisterInitializeSpy LIB "ole32.dll" ALIAS "CoRegisterInitializeSpy" ( BYVAL lpInitializeSpy AS IInitializeSpy , BYVAL pUliCookie AS QUAD ) AS LONG
DECLARE FUNCTION CoRevokeInitializeSpy LIB "ole32.dll" ALIAS "CoRevokeInitializeSpy" ( BYVAL uliCookie AS QUAD
 ) AS LONG
DECLARE FUNCTION CoGetContextToken LIB "ole32.dll" ALIAS "CoGetContextToken" ( BYREF pToken AS ANY
 ) AS LONG
'// COM System Security Descriptors (used when the corresponding registry
'// entries are absent)
' COMSD enum
%EQUATE `SD_LAUNCHPERMISSIONS = 0 ' // Machine wide launch permissions
%EQUATE `SD_ACCESSPERMISSIONS = 1 ' // Machine wide acesss permissions
%EQUATE `SD_LAUNCHRESTRICTIONS = 2 ' // Machine wide launch limits
%EQUATE `SD_ACCESSRESTRICTIONS = 3 ' // Machine wide access limits
DECLARE FUNCTION CoGetSystemSecurityPermissions LIB "ole32.dll" ALIAS "CoGetSystemSecurityPermissions" ( BYVAL comSDType AS LONG ) AS LONG ' COMSD comSDType , BYREF ppSD AS SECURITY_DESCRIPTOR ' PSECURITY_DESCRIPTOR *ppSD
'#endif
'// definition for Win7 new APIs
'#if (_WIN32_WINNT >= _NT_TARGET_VERSION_WIN7)
DECLARE FUNCTION CoGetApartmentType LIB "ole32.dll" ALIAS "CoGetApartmentType" ( BYREF pAptType AS LONG , BYREF pAptQualifier AS LONG ) AS LONG
'#endif
'#if DBG == 1
'WINOLEAPI_(ULONG) DebugCoGetRpcFault( void );
'WINOLEAPI_(void) DebugCoSetRpcFault( ULONG );
'#endif
'#if (_WIN32_WINNT >= 0x0500)
' // Size = 60 bytes
TYPE SOleTlsDataPublic DWORD
 pvReserved0(1) AS DWORD PTR ' void* [2]
 dwReserved0(2) AS DWORD ' DWORD [3]
 pvReserved1(0) AS DWORD PTR ' void* [1]
 dwReserved1(2) AS DWORD ' DWORD [3]
 pvReserved2(3) AS DWORD PTR ' void* [4]
 dwReserved2(0) AS DWORD ' DWORD [1]
 pCurrentCtx AS DWORD PTR ' void*
END TYPE
MACRO SOleTlsData = SOleTlsDataPublic
'#endif
'/* COM+ APIs */
DECLARE FUNCTION CoGetObjectContext LIB "ole32.dll" ALIAS "CoGetObjectContext" ( BYREF riid AS GUID , BYREF ppv AS ANY ) AS LONG
'/* register/revoke/get class objects */
DECLARE FUNCTION CoGetClassObject LIB "ole32.dll" ALIAS "CoGetClassObject" ( BYREF rclsid AS GUID , BYVAL dwClsContext AS QUAD , BYREF pServerInfo AS COSERVERINFO , BYREF riid AS GUID , BYREF ppv AS ANY ) AS LONG
DECLARE FUNCTION CoRegisterClassObject LIB "ole32.dll" ALIAS "CoRegisterClassObject" ( BYREF rclsid AS GUID
 , BYVAL pUnk AS IUnknown
 , BYVAL dwClsContext AS DWORD
 , BYVAL flags AS DWORD
 , BYREF lpdwRegister AS DWORD
 ) AS LONG
DECLARE FUNCTION CoRevokeClassObject LIB "ole32.dll" ALIAS "CoRevokeClassObject" ( BYVAL dwRegister AS DWORD
 ) AS LONG
DECLARE FUNCTION CoResumeClassObjects LIB "ole32.dll" ALIAS "CoResumeClassObjects" ( ) AS LONG
DECLARE FUNCTION CoSuspendClassObjects LIB "ole32.dll" ALIAS "CoSuspendClassObjects" ( ) AS LONG
DECLARE FUNCTION CoAddRefServerProcess LIB "ole32.dll" ALIAS "CoAddRefServerProcess" ( ) AS DWORD ' ULONG
DECLARE FUNCTION CoReleaseServerProcess LIB "ole32.dll" ALIAS "CoReleaseServerProcess" ( ) AS QUAD ' ULONG
DECLARE FUNCTION CoGetPSClsid LIB "ole32.dll" ALIAS "CoGetPSClsid" ( BYREF riid AS GUID , BYREF pclsid AS GUID ) AS LONG
DECLARE FUNCTION CoRegisterPSClsid LIB "ole32.dll" ALIAS "CoRegisterPSClsid" ( BYREF riid AS GUID
 , BYREF rclsid AS GUID
 ) AS LONG
'// Registering surrogate processes
DECLARE FUNCTION CoRegisterSurrogate LIB "ole32.dll" ALIAS "CoRegisterSurrogate" ( BYVAL pSurrogate AS ISurrogate ) AS LONG
'/* marshaling interface pointers */
DECLARE FUNCTION CoGetMarshalSizeMax LIB "ole32.dll" ALIAS "CoGetMarshalSizeMax" ( BYREF pulSize AS QUAD , BYREF riid AS GUID , BYVAL pUnk AS IUnknown , BYVAL dwDestContext AS QUAD , BYVAL pvDestContext AS QUAD , BYVAL mshlflags AS QUAD ) AS LONG
DECLARE FUNCTION CoMarshalInterface LIB "ole32.dll" ALIAS "CoMarshalInterface" ( BYVAL pStm AS IStream
 , BYREF riid AS GUID
 , BYVAL pUnk AS IUnknown
 , BYVAL dwDestContext AS DWORD
 , BYVAL pvDestContext AS DWORD
 , BYVAL mshlflags AS DWORD
 ) AS LONG
DECLARE FUNCTION CoUnmarshalInterface LIB "ole32.dll" ALIAS "CoUnmarshalInterface" ( BYVAL pStm AS IStream
 , BYREF riid AS GUID
 , BYREF ppv AS ANY
 ) AS LONG
DECLARE FUNCTION CoMarshalHresult LIB "ole32.dll" ALIAS "CoMarshalHresult" ( BYVAL pStm AS IStream
 , BYVAL hresult AS LONG
 ) AS LONG
DECLARE FUNCTION CoUnmarshalHresult LIB "ole32.dll" ALIAS "CoUnmarshalHresult" ( BYVAL pStm AS IStream
 , BYREF phresult AS DWORD
 ) AS LONG
DECLARE FUNCTION CoReleaseMarshalData LIB "ole32.dll" ALIAS "CoReleaseMarshalData" ( BYVAL pStm AS IStream
 ) AS LONG
DECLARE FUNCTION CoDisconnectObject LIB "ole32.dll" ALIAS "CoDisconnectObject" ( BYVAL pUnk AS IUnknown
 , BYVAL dwReserved AS DWORD
 ) AS LONG
DECLARE FUNCTION CoLockObjectExternal LIB "ole32.dll" ALIAS "CoLockObjectExternal" ( BYVAL pUnk AS IUnknown
 , BYVAL fLock AS LONG
 , BYVAL fLastUnlockReleases AS LONG
 ) AS LONG
DECLARE FUNCTION CoGetStandardMarshal LIB "ole32.dll" ALIAS "CoGetStandardMarshal" ( BYREF riid AS GUID
 , BYVAL pUnk AS IUnknown
 , BYVAL dwDestContext AS DWORD
 , BYVAL pvDestContext AS DWORD
 , BYVAL mshlflags AS DWORD
 , BYREF ppMarshal AS IMarshal
 ) AS LONG
DECLARE FUNCTION CoGetStdMarshalEx LIB "ole32.dll" ALIAS "CoGetStdMarshalEx" ( BYVAL pUnkOuter AS IUnknown
 , BYVAL dwSMEXFlags AS DWORD
 , BYREF ppUnkInner AS IUnknown
 ) AS LONG
'/* flags for CoGetStdMarshalEx */
%EQUATE `SMEXF_SERVER = &H01 ' // server side aggregated std marshaler
%EQUATE `SMEXF_HANDLER = &H02 ' // client side (handler) agg std marshaler
DECLARE FUNCTION CoIsHandlerConnected LIB "ole32.dll" ALIAS "CoIsHandlerConnected" ( BYVAL pUnk AS IUnknown ) AS LONG
'// Apartment model inter-thread interface passing helpers
DECLARE FUNCTION CoMarshalInterThreadInterfaceInStream LIB "ole32.dll" ALIAS "CoMarshalInterThreadInterfaceInStream" ( BYREF riid AS GUID , BYVAL pUnk AS IUnknown , BYREF ppStm AS IStream ) AS LONG
DECLARE FUNCTION CoGetInterfaceAndReleaseStream LIB "ole32.dll" ALIAS "CoGetInterfaceAndReleaseStream" ( BYVAL pStm AS IStream
 , BYREF riid AS GUID
 , BYREF ppv AS ANY
 ) AS LONG
DECLARE FUNCTION CoCreateFreeThreadedMarshaler LIB "ole32.dll" ALIAS "CoCreateFreeThreadedMarshaler" ( BYVAL punkOuter AS IUnknown
 , BYREF ppunkMarshaler AS IUnknown
 ) AS LONG
'/* dll loading helpers; keeps track of ref counts and unloads all on exit */
DECLARE FUNCTION CoLoadLibrary LIB "ole32.dll" ALIAS "CoLoadLibrary" ( BYREF lpszLibName AS WSTRINGZ , BYVAL bAutoFree AS LONG ) AS QUAD ' HINSTANCE
DECLARE SUB CoFreeLibrary LIB "ole32.dll" ALIAS "CoFreeLibrary" ( BYVAL hInst AS QUAD ) ' void
DECLARE SUB CoFreeAllLibraries LIB "ole32.dll" ALIAS "CoFreeAllLibraries" () ' void
DECLARE SUB CoFreeUnusedLibraries LIB "ole32.dll" ALIAS "CoFreeUnusedLibraries" () ' void
'#if (_WIN32_WINNT >= 0x0501)
DECLARE SUB CoFreeUnusedLibrariesEx LIB "ole32.dll" ALIAS "CoFreeUnusedLibraries" ( BYVAL dwUnloadDelay AS QUAD , BYVAL dwReserved AS QUAD ) ' void
'#endif
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION CoDisconnectContext LIB "ole32.dll" ALIAS "CoDisconnectContext" ( BYVAL dwTimeout AS QUAD ) AS QUAD ' HINSTANCE
#ENDIF
'#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
'/* Call Security. */
DECLARE FUNCTION CoInitializeSecurity LIB "ole32.dll" ALIAS "CoInitializeSecurity" ( BYREF pVoid AS SECURITY_DESCRIPTOR , BYVAL cAuthSvc AS LONG , BYREF asAuthSvc AS SOLE_AUTHENTICATION_SERVICE , BYVAL pReserved1 AS QUAD , BYVAL dwAuthnLevel AS QUAD , BYVAL dwImpLevel AS QUAD , BYREF pAuthList AS SOLE_AUTHENTICATION_LIST , BYVAL dwCapabilities AS QUAD , BYVAL pReserved3 AS QUAD ) AS LONG
DECLARE FUNCTION CoGetCallContext LIB "ole32.dll" ALIAS "CoGetCallContext" ( BYREF riid AS GUID
 , BYREF ppInterface AS ANY
 ) AS LONG
DECLARE FUNCTION CoQueryProxyBlanket LIB "ole32.dll" ALIAS "CoQueryProxyBlanket" ( BYVAL pProxy AS IUnknown
 , BYREF pAuthnSvc AS DWORD
 , BYREF pAuthzSvc AS DWORD
 , BYREF pServerPrincName AS DWORD
 , BYREF pAuthnLevel AS DWORD
 , BYREF pImpLevel AS DWORD
 , BYREF ppAuthInfo AS DWORD
 , BYREF pCapabilities AS DWORD
 ) AS LONG
DECLARE FUNCTION CoSetProxyBlanket LIB "ole32.dll" ALIAS "CoSetProxyBlanket" ( BYVAL pProxy AS IUnknown
 , BYVAL dwAuthnSvc AS DWORD
 , BYVAL dwAuthzSvc AS DWORD
 , BYVAL pServerPrincName AS DWORD
 , BYVAL dwAuthnLevel AS DWORD
 , BYVAL dwImpLevel AS DWORD
 , BYVAL pAuthInfo AS DWORD
 , BYVAL dwCapabilities AS DWORD
 ) AS LONG
DECLARE FUNCTION CoCopyProxy LIB "ole32.dll" ALIAS "CoCopyProxy" ( BYVAL pProxy AS IUnknown
 , BYREF ppCopy AS IUnknown
 ) AS LONG
DECLARE FUNCTION CoQueryClientBlanket LIB "ole32.dll" ALIAS "CoQueryClientBlanket" ( BYREF pAuthnSvc AS DWORD
 , BYREF pAuthzSvc AS DWORD
 , BYREF pServerPrincName AS DWORD
 , BYREF pAuthnLevel AS DWORD
 , BYREF pImpLevel AS DWORD
 , BYREF pPrivs AS DWORD
 , BYREF pCapabilities AS DWORD
 ) AS LONG
DECLARE FUNCTION CoImpersonateClient LIB "ole32.dll" ALIAS "CoImpersonateClient" ( ) AS LONG
DECLARE FUNCTION CoRevertToSelf LIB "ole32.dll" ALIAS "CoRevertToSelf" ( ) AS LONG
DECLARE FUNCTION CoQueryAuthenticationServices LIB "ole32.dll" ALIAS "CoQueryAuthenticationServices" ( BYREF pcAuthSvc AS DWORD
 , BYREF asAuthSvc AS DWORD
 ) AS LONG
DECLARE FUNCTION CoSwitchCallContext LIB "ole32.dll" ALIAS "CoSwitchCallContext" ( BYVAL pNewObject AS IUnknown
 , BYREF ppOldObject AS IUnknown
 ) AS LONG
%EQUATE `COM_RIGHTS_EXECUTE = 1
%EQUATE `COM_RIGHTS_EXECUTE_LOCAL = 2
%EQUATE `COM_RIGHTS_EXECUTE_REMOTE = 4
%EQUATE `COM_RIGHTS_ACTIVATE_LOCAL = 8
%EQUATE `COM_RIGHTS_ACTIVATE_REMOTE = 16
'#endif // DCOM
'/* helper for creating instances */
DECLARE FUNCTION CoCreateInstance LIB "ole32.dll" ALIAS "CoCreateInstance" ( BYREF rclsid AS GUID , BYVAL pUnkOuter AS IUnknown , BYVAL dwClsContext AS QUAD , BYREF riid AS GUID , BYREF ppv AS ANY ) AS LONG
'#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
DECLARE FUNCTION CoGetInstanceFromFile LIB "ole32.dll" ALIAS "CoGetInstanceFromFile" ( BYREF pServerInfo AS COSERVERINFO , BYREF pclsid AS GUID , BYVAL punkOuter AS IUnknown , BYVAL dwClsCtx AS QUAD , BYVAL grfMode AS QUAD , BYREF szName AS WSTRINGZ , BYVAL cmq AS QUAD , BYREF rgmqResults AS MULTI_QI ) AS LONG
DECLARE FUNCTION CoGetInstanceFromIStorage LIB "ole32.dll" ALIAS "CoGetInstanceFromIStorage" ( BYREF pServerInfo AS COSERVERINFO
 , BYREF pclsid AS GUID
 , BYVAL punkOuter AS IUnknown
 , BYVAL dwClsCtx AS DWORD
 , BYVAL pstg AS IStorage
 , BYVAL cmq AS DWORD
 , BYREF rgmqResults AS MULTI_QI
 ) AS LONG
DECLARE FUNCTION CoCreateInstanceEx LIB "ole32.dll" ALIAS "CoCreateInstanceEx" ( BYREF rclsid AS GUID
 , BYVAL punkOuter AS IUnknown
 , BYVAL dwClsCtx AS DWORD
 , BYREF pServerInfo AS COSERVERINFO
 , BYVAL cmq AS LONG
 , BYREF pResults AS MULTI_QI
 ) AS LONG
'#endif // DCOM
'/* Call related APIs */
'#if (_WIN32_WINNT >= 0x0500 ) || defined(_WIN32_DCOM) // DCOM
DECLARE FUNCTION CoGetCancelObject LIB "ole32.dll" ALIAS "CoGetCancelObject" ( BYVAL dwThreadID AS QUAD , BYREF riid AS GUID , BYREF ppUnk AS ANY ) AS LONG
DECLARE FUNCTION CoSetCancelObject LIB "ole32.dll" ALIAS "CoSetCancelObject" ( BYVAL pUnk AS IUnknown
 ) AS LONG
DECLARE FUNCTION CoCancelCall LIB "ole32.dll" ALIAS "CoCancelCall" ( BYVAL dwThreadID AS DWORD
 , BYVAL ulTimeout AS DWORD
 ) AS LONG
DECLARE FUNCTION CoTestCancel LIB "ole32.dll" ALIAS "CoTestCancel" ( ) AS LONG
DECLARE FUNCTION CoEnableCallCancellation LIB "ole32.dll" ALIAS "CoEnableCallCancellation" ( BYVAL pvReserved AS DWORD
 ) AS LONG
DECLARE FUNCTION CoDisableCallCancellation LIB "ole32.dll" ALIAS "CoDisableCallCancellation" ( BYVAL pvReserved AS DWORD
 ) AS LONG
DECLARE FUNCTION CoAllowSetForegroundWindow LIB "ole32.dll" ALIAS "CoAllowSetForegroundWindow" ( BYVAL pUnk AS IUnknown
 , BYVAL lpvReserved AS DWORD
 ) AS LONG
DECLARE FUNCTION DcomChannelSetHResult LIB "ole32.dll" ALIAS "DcomChannelSetHResult" ( BYVAL pvReserved AS DWORD
 , BYVAL pulReserved AS DWORD
 , BYVAL appsHR AS LONG
 ) AS LONG
'#endif
'/* other helpers */
DECLARE FUNCTION StringFromCLSID LIB "ole32.dll" ALIAS "StringFromCLSID" ( BYREF rclsid AS GUID , BYREF ppsz AS QUAD ) AS LONG
DECLARE FUNCTION CLSIDFromString LIB "ole32.dll" ALIAS "CLSIDFromString" ( BYREF lpsz AS WSTRINGZ
 , BYREF pclsid AS GUID
 ) AS LONG
DECLARE FUNCTION StringFromIID LIB "ole32.dll" ALIAS "StringFromIID" ( BYREF rclsid AS GUID
 , BYREF lplpsz AS DWORD
 ) AS LONG
DECLARE FUNCTION IIDFromString LIB "ole32.dll" ALIAS "IIDFromtString" ( BYREF lpsz AS WSTRINGZ
 , BYREF lpiid AS GUID
 ) AS LONG
DECLARE FUNCTION CoIsOle1Class LIB "ole32.dll" ALIAS "CoIsOle1Class" ( BYREF rclsid AS GUID
 ) AS LONG
DECLARE FUNCTION ProgIDFromCLSID LIB "ole32.dll" ALIAS "ProgIDFromCLSID" ( BYREF clsid AS GUID
 , BYREF lplpszProgID AS DWORD
 ) AS LONG
DECLARE FUNCTION CLSIDFromProgID LIB "ole32.dll" ALIAS "CLSIDFromProgID" ( BYREF lpszProgID AS WSTRINGZ
 , BYREF pclsid AS GUID
 ) AS LONG
DECLARE FUNCTION CLSIDFromProgIDEx LIB "ole32.dll" ALIAS "CLSIDFromProgIDEx" ( BYREF lpszProgID AS WSTRINGZ
 , BYREF pclsid AS GUID
 ) AS LONG
DECLARE FUNCTION StringFromGUID2 LIB "ole32.dll" ALIAS "StringFromGUID2" ( BYREF rguid AS GUID
 , BYREF lpsz AS WSTRINGZ
 , BYVAL cchMax AS LONG
 ) AS LONG ' int
DECLARE FUNCTION CoCreateGuid LIB "ole32.dll" ALIAS "CoCreateGuid" ( BYREF pguid AS GUID ) AS LONG
DECLARE FUNCTION CoFileTimeToDosDateTime LIB "ole32.dll" ALIAS "CoFileTimeToDosDateTime" ( BYREF lpFileTime AS FILETIME
 , BYREF lpDosDate AS WORD
 , BYREF lpDosTime AS WORD
 ) AS LONG
DECLARE FUNCTION CoDosDateTimeToFileTime LIB "ole32.dll" ALIAS "CoDosDateTimeToFileTime" ( BYVAL nDosDate AS WORD
 , BYVAL nDosTime AS WORD
 , BYREF lpFileTime AS FILETIME
 ) AS LONG
DECLARE FUNCTION CoFileTimeNow LIB "ole32.dll" ALIAS "CoFileTimeNow" ( BYREF lpFileTime AS FILETIME
 ) AS LONG
DECLARE FUNCTION CoRegisterMessageFilter LIB "ole32.dll" ALIAS "CoRegisterMessageFilter" ( BYVAL lpMessageFilter AS IMessageFilter
 , BYREF lplpMessageFilter AS IMessageFilter
 ) AS LONG
'#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
DECLARE FUNCTION CoRegisterChannelHook LIB "ole32.dll" ALIAS "CoRegisterChannelHook" ( BYREF ExtensionUuid AS GUID , BYVAL pChannelHook AS IUnknown ) AS LONG
'#endif // DCOM
'#IF %DEF(%WIN32_DCOM) ' // DCOM
'#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
'/* Synchronization API */
DECLARE FUNCTION CoWaitForMultipleHandles LIB "ole32.dll" ALIAS "CoWaitForMultipleHandles" ( BYVAL dwFlags AS QUAD , BYVAL dwTimeout AS QUAD , BYVAL cHandles AS QUAD , BYVAL pHandles AS QUAD , BYREF lpdwindex AS QUAD ) AS LONG
'/* Flags for Synchronization API and Classes */
' enum COWAIT_FLAGS
%EQUATE `COWAIT_WAITALL = 1
%EQUATE `COWAIT_ALERTABLE = 2
%EQUATE `COWAIT_INPUTAVAILABLE = 4
'#endif // DCOM
'#ENDIF ' // DCOM
'/* for flushing OLESCM remote binding handles */
'#if (_WIN32_WINNT >= 0x0501)
DECLARE FUNCTION CoInvalidateRemoteMachineBindings LIB "ole32.dll" ALIAS "CoInvalidateRemoteMachineBindings" ( BYREF pszMachineName AS WSTRINGZ ) AS LONG
'#endif
'/* TreatAs APIS */
DECLARE FUNCTION CoGetTreatAsClass LIB "ole32.dll" ALIAS "CoGetTreatAsClass" ( BYREF clsidOld AS GUID , BYREF pclsidNew AS GUID ) AS LONG
DECLARE FUNCTION CoTreatAsClass LIB "ole32.dll" ALIAS "CoTreatAsClass" ( BYREF clsidOld AS GUID
 , BYREF clsidNew AS GUID
 ) AS LONG
'/* the server dlls must define their DllGetClassObject and DllCanUnloadNow
' * to match these; the typedefs are located here to ensure all are changed at
' * the same time.
' */
'typedef HRESULT (STDAPICALLTYPE * LPFNGETCLASSOBJECT) (REFCLSID, REFIID, LPVOID *);
'typedef HRESULT (STDAPICALLTYPE * LPFNCANUNLOADNOW)(void);
'STDAPI DllGetClassObject(IN REFCLSID rclsid, IN REFIID riid, OUT LPVOID FAR* ppv);
DECLARE FUNCTION DllGetClassObject (BYREF rclsid AS GUID, BYREF riid AS GUID, BYREF ppv AS ANY) AS LONG
'STDAPI DllCanUnloadNow(void);
DECLARE FUNCTION DllCanUnloadNow () AS LONG
'/****** Default Memory Allocation ******************************************/
DECLARE FUNCTION CoTaskMemAlloc LIB "ole32.dll" ALIAS "CoTaskMemAlloc" ( BYVAL cb AS QUAD ) AS QUAD
DECLARE FUNCTION CoTaskMemRealloc LIB "ole32.dll" ALIAS "CoTaskMemRealloc" ( BYVAL pv AS QUAD
 , BYVAL cb AS DWORD
 ) AS DWORD
DECLARE SUB CoTaskMemFree LIB "ole32.dll" ALIAS "CoTaskMemFree" ( BYVAL pv AS DWORD
 ) ' void
'/****** DV APIs ***********************************************************/
'/* This function is declared in objbase.h and ole2.h */
DECLARE FUNCTION CreateDataAdviseHolder LIB "ole32.dll" ALIAS "CreateDataAdviseHolder" ( BYREF ppDAHolder AS IDataAdviseHolder ) AS LONG
DECLARE FUNCTION CreateDataCache LIB "ole32.dll" ALIAS "CreateDataCache" ( BYVAL pUnkOuter AS IUnknown
 , BYREF rclsid AS GUID
 , BYREF riid AS GUID
 , BYREF ppvObj AS ANY
 ) AS LONG
'/****** Storage API Prototypes ********************************************/
DECLARE FUNCTION StgCreateDocFile LIB "ole32.dll" ALIAS "StgCreateDocfile" ( BYREF pwcsName AS WSTRINGZ , BYVAL grfMode AS QUAD , BYVAL reserved AS QUAD , BYREF ppstgOpen AS IStorage ) AS LONG
DECLARE FUNCTION StgCreateDocfileOnILockBytes LIB "ole32.dll" ALIAS "StgCreateDocfileOnILockBytes" ( BYVAL plkbyt AS ILockBytes
 , BYVAL grfMode AS DWORD
 , BYVAL reserved AS DWORD
 , BYREF ppstgOpen AS IStorage
 ) AS LONG
DECLARE FUNCTION StgOpenStorage LIB "ole32.dll" ALIAS "StgOpenStorage" ( BYREF pwcsName AS WSTRINGZ
 , BYVAL pstgPriority AS IStorage
 , BYVAL grfMode AS DWORD
 , BYVAL snbExclude AS DWORD
 , BYVAL reserved AS DWORD
 , BYREF ppstgOpen AS IStorage
 ) AS LONG
DECLARE FUNCTION StgOpenStorageOnILockBytes LIB "ole32.dll" ALIAS "StgOpenStorageOnILockBytes" ( BYVAL plkbyt AS ILockBytes
 , BYVAL pStgPriority AS IStorage
 , BYVAL grfMode AS DWORD
 , BYVAL snbExclude AS DWORD
 , BYVAL reserved AS DWORD
 , BYREF ppstgOpen AS IStorage
 ) AS LONG
DECLARE FUNCTION StgIsStorageFile LIB "ole32.dll" ALIAS "StgIsStorageFile" ( BYREF pwcsName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION StgIsStorageILockBytes LIB "ole32.dll" ALIAS "StgIsStorageILockBytes" ( BYVAL plkbyt AS ILockBytes
 ) AS LONG
DECLARE FUNCTION StgSetTimes LIB "ole32.dll" ALIAS "StgSetTimes" ( BYREF lpszName AS WSTRINGZ
 , BYREF pctime AS FILETIME
 , BYREF patime AS FILETIME
 , BYREF pmtime AS FILETIME
 ) AS LONG
DECLARE FUNCTION StgOpenAsyncDocfileOnIFillLockBytes LIB "ole32.dll" ALIAS "StgOpenAsyncDocfileOnIFillLockBytes" ( BYVAL ppflb AS IFillLockBytes
 , BYVAL grfmode AS DWORD
 , BYVAL asyncFlags AS DWORD
 , BYREF ppstgOpen AS IStorage
 ) AS LONG
DECLARE FUNCTION StgGetIFillLockBytesOnILockBytes LIB "ole32.dll" ALIAS "StgGetIFillLockBytesOnILockBytes" ( BYVAL pilb AS ILockBytes
 , BYREF ppflb AS IFillLockBytes
 ) AS LONG
DECLARE FUNCTION StgGetIFillLockBytesOnFile LIB "ole32.dll" ALIAS "StgGetIFillLockBytesOnFile" ( BYREF pwcsName AS WSTRINGZ
 , BYREF ppflb AS IFillLockBytes
 ) AS LONG
' Note Do not use this function. Use the IStorage::CopyTo method instead.
' CopyTo can be used to layout a docfile, thus improving performance in most scenarios.
'WINOLEAPI StgOpenLayoutDocfile(IN OLECHAR const *pwcsDfName,
' IN DWORD grfMode,
' IN DWORD reserved,
' OUT IStorage **ppstgOpen);
'// STG initialization options for StgCreateStorageEx and StgOpenStorageEx
'#if _WIN32_WINNT == 0x500
'#define STGOPTIONS_VERSION 1
'#elif _WIN32_WINNT > 0x500
'#define STGOPTIONS_VERSION 2
'#else
'#define STGOPTIONS_VERSION 0
'#endif
#IF %WINVER = &H500
 %STGOPTIONS_VERSION = 1
#ELSEIF %WINVER > &H500
 %STGOPTIONS_VERSION = 2
#ELSE
 %STGOPTIONS_VERSION = 0
#ENDIF
'typedef struct tagSTGOPTIONS
'{
' USHORT usVersion; // Versions 1 and 2 supported
' USHORT reserved; // must be 0 for padding
' ULONG ulSectorSize; // docfile header sector size (512)
'#if STGOPTIONS_VERSION >= 2
' const WCHAR *pwcsTemplateFile; // version 2 or above
'#endif
'} STGOPTIONS;
' // Size = 8/12 bytes
TYPE STGOPTIONS
 usVersion AS WORD ' // Versions 1 and 2 supported
 reserved AS WORD ' // must be 0 for padding
 ulSectorSize AS DWORD ' // docfile header sector size (512)
#IF %STGOPTIONS_VERSION >= 2
 pwcsTemplateFile AS DWORD ' // version 2 or above
#ENDIF
END TYPE
DECLARE FUNCTION StgCreateStorageEx LIB "ole32.dll" ALIAS "StgCreateStorageEx" ( BYREF pwcsName AS WSTRINGZ , BYVAL grfMode AS QUAD , BYVAL stgfmt AS QUAD , BYVAL grfAttrs AS QUAD , BYREF pStgOptions AS STGOPTIONS , BYVAL reserved2 AS QUAD , BYREF riid AS GUID , BYREF ppObjectOpen AS ANY ) AS LONG
DECLARE FUNCTION StgOpenStorageEx LIB "ole32.dll" ALIAS "StgOpenStorageEx" ( BYREF pwcsName AS WSTRINGZ
 , BYVAL grfMode AS DWORD
 , BYVAL stgfmt AS DWORD
 , BYVAL grfAttrs AS DWORD
 , BYREF pStgOptions AS STGOPTIONS
 , BYVAL reserved2 AS DWORD
 , BYREF riid AS GUID
 , BYREF ppObjectOpen AS ANY
 ) AS LONG
'//
'// Moniker APIs
'//
DECLARE FUNCTION BindMoniker LIB "ole32.dll" ALIAS "BindMoniker" ( BYVAL pmk AS IMoniker , BYVAL grfOpt AS QUAD , BYREF iidResult AS GUID , BYREF ppvResult AS ANY ) AS LONG
DECLARE FUNCTION CoInstall LIB "ole32.dll" ALIAS "CoInstall" ( BYVAL pbc AS IBindCtx
 , BYVAL dwFlags AS DWORD
 , BYREF pClassSpec AS uCLSSPEC
 , BYVAL pQuery AS QUERYCONTEXT
 , BYREF pszCodeBase AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION CoGetObject LIB "ole32.dll" ALIAS "CoGetObject" ( BYREF pszName AS WSTRINGZ
 , BYREF pBindOptions AS BIND_OPTS
 , BYREF riid AS GUID
 , BYREF ppv AS ANY
 ) AS LONG
DECLARE FUNCTION MkParseDisplayName LIB "ole32.dll" ALIAS "MkParseDisplayName" ( BYVAL pbc AS IBindCtx
 , BYREF szUserName AS WSTRINGZ
 , BYREF pchEaten AS DWORD
 , BYREF ppmk AS IMoniker
 ) AS LONG
DECLARE FUNCTION MonikerRelativePathTo LIB "ole32.dll" ALIAS "MonikerRelativePathTo" ( BYVAL pmkSrc AS IMoniker
 , BYVAL pmkDest AS IMoniker
 , BYREF ppmkRelPath AS IMoniker
 , BYVAL dwReserved AS LONG
 ) AS LONG
DECLARE FUNCTION MonikerCommonPrefixWith LIB "ole32.dll" ALIAS "MonikerCommonPrefixWith" ( BYVAL pmkThis AS IMoniker
 , BYVAL pmkOther AS IMoniker
 , BYREF ppmkCommon AS IMoniker
 ) AS LONG
DECLARE FUNCTION CreateBindCtx LIB "ole32.dll" ALIAS "CreateBindCtx" ( BYVAL reserved AS DWORD
 , BYREF ppbc AS IBindCtx
 ) AS LONG
DECLARE FUNCTION CreateGenericComposite LIB "ole32.dll" ALIAS "CreateGenericComposite" ( BYVAL pmkFirst AS IMoniker
 , BYVAL pmkRest AS IMoniker
 , BYREF ppmkComposite AS IMoniker
 ) AS LONG
DECLARE FUNCTION GetClassFile LIB "ole32.dll" ALIAS "GetClassFile" ( BYREF szFileName AS WSTRINGZ
 , BYREF pclsid AS GUID
 ) AS LONG
DECLARE FUNCTION CreateClassMoniker LIB "ole32.dll" ALIAS "CreateClassMoniker" ( BYREF rclsid AS GUID
 , BYREF ppmk AS IMoniker
 ) AS LONG
DECLARE FUNCTION CreateFileMoniker LIB "ole32.dll" ALIAS "CreateFileMoniker" ( BYREF lpszPathName AS WSTRINGZ
 , BYREF ppmk AS IMoniker
 ) AS LONG
DECLARE FUNCTION CreateItemMoniker LIB "ole32.dll" ALIAS "CreateItemMoniker" ( BYREF lpszDelim AS WSTRINGZ
 , BYREF lpszItem AS WSTRINGZ
 , BYREF ppmk AS IMoniker
 ) AS LONG
DECLARE FUNCTION CreateAntiMoniker LIB "ole32.dll" ALIAS "CreateAntiMoniker" ( __
 BYREF ppmk AS IMoniker
 ) AS LONG
DECLARE FUNCTION CreatePointerMoniker LIB "ole32.dll" ALIAS "CreatePointerMoniker" ( BYVAL punk AS IUnknown
 , BYREF ppmk AS IMoniker
 ) AS LONG
DECLARE FUNCTION CreateObjrefMoniker LIB "ole32.dll" ALIAS "CreateObjrefMoniker" ( BYVAL pUnk AS IUnknown
 , BYREF ppMk AS IMoniker
 ) AS LONG
DECLARE FUNCTION GetRunningObjectTable LIB "ole32.dll" ALIAS "GetRunningObjectTable" ( BYVAL reserved AS DWORD
 , BYREF pprot AS IRunningObjectTable
 ) AS LONG
#INCLUDE ONCE "Legacy/Network/UrlMon.inc"
#INCLUDE ONCE "Legacy/System/PropIdl.inc"
'//
'// Standard Progress Indicator impolementation
'//
DECLARE FUNCTION CreateStdProgressIndicator LIB "ole32.dll" ALIAS "CreateStdProgressIndicator" ( BYVAL hwndParent AS QUAD , BYREF pszTitle AS WSTRINGZ , BYVAL pIbscCaller AS IBindStatusCallback , BYREF ppIbsc AS IBindStatusCallback ) AS LONG
#ENDIF
