1 /***********************************************************************\
2 *                               objbase.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                                                                       *
8 *                       Placed into public domain                       *
9 \***********************************************************************/
10 module windows.objbase;
11 pragma(lib, "ole32");
12 nothrow:
13 import windows.cguid, windows.objidl, windows.unknwn, windows.wtypes;
14 private import windows.basetyps, windows.objfwd, windows.rpcdce, windows.winbase,
15   windows.windef;
16 
17 // DAC: Not needed for D?
18 //MACRO #define LISet32(li, v) ((li).HighPart=(v)<0?-1:0, (li).LowPart=(v))
19 //MACRO #define ULISet32(li, v) ((li).HighPart=0, (li).LowPart=(v))
20 
21 const CLSCTX_ALL    = CLSCTX.CLSCTX_INPROC_SERVER|CLSCTX.CLSCTX_INPROC_HANDLER|CLSCTX.CLSCTX_LOCAL_SERVER;
22 const CLSCTX_INPROC = CLSCTX.CLSCTX_INPROC_SERVER|CLSCTX.CLSCTX_INPROC_HANDLER;
23 const CLSCTX_SERVER = CLSCTX.CLSCTX_INPROC_SERVER|CLSCTX.CLSCTX_LOCAL_SERVER|CLSCTX.CLSCTX_REMOTE_SERVER;
24 const MARSHALINTERFACE_MIN=500;
25 const CWCSTORAGENAME=32;
26 
27 const STGM_DIRECT           = 0;
28 const STGM_TRANSACTED       = 0x10000L;
29 const STGM_SIMPLE           = 0x8000000L;
30 const STGM_READ             = 0;
31 const STGM_WRITE            = 1;
32 const STGM_READWRITE        = 2;
33 const STGM_SHARE_DENY_NONE  = 0x40;
34 const STGM_SHARE_DENY_READ  = 0x30;
35 const STGM_SHARE_DENY_WRITE = 0x20;
36 const STGM_SHARE_EXCLUSIVE  = 0x10;
37 const STGM_PRIORITY         = 0x40000L;
38 const STGM_DELETEONRELEASE  = 0x4000000;
39 const STGM_NOSCRATCH        = 0x100000;
40 const STGM_CREATE           = 0x1000;
41 const STGM_CONVERT          = 0x20000;
42 const STGM_NOSNAPSHOT       = 0x200000;
43 const STGM_FAILIFTHERE      = 0;
44 
45 const ASYNC_MODE_COMPATIBILITY = 1;
46 const ASYNC_MODE_DEFAULT       = 0;
47 
48 const STGTY_REPEAT = 256;
49 const STG_TOEND = 0xFFFFFFFF;
50 const STG_LAYOUT_SEQUENTIAL  = 0;
51 const STG_LAYOUT_INTERLEAVED = 1;
52 
53 const COM_RIGHTS_EXECUTE            = 1;
54 const COM_RIGHTS_SAFE_FOR_SCRIPTING = 2;
55 
56 const STGOPTIONS_VERSION = 2;
57 
58 enum STGFMT {
59 	STGFMT_STORAGE = 0,
60 	STGFMT_FILE = 3,
61 	STGFMT_ANY = 4,
62 	STGFMT_DOCFILE = 5
63 }
64 
65 struct STGOPTIONS {
66 	USHORT usVersion;
67 	USHORT reserved;
68 	ULONG ulSectorSize;
69 	const(WCHAR)* pwcsTemplateFile;
70 }
71 
72 enum REGCLS {
73 	REGCLS_SINGLEUSE = 0,
74 	REGCLS_MULTIPLEUSE = 1,
75 	REGCLS_MULTI_SEPARATE = 2
76 }
77 
78 /*
79 BOOL IsEqualGUID(GUID rguid1, GUID rguid2) {
80 	return rguid1 == rguid2;
81 }
82 */
83 
84 extern (Windows) BOOL IsEqualGUID(
85   REFGUID rguid1,
86   REFGUID rguid2
87 );
88 
89 alias IsEqualGUID IsEqualIID;
90 alias IsEqualGUID IsEqualCLSID;
91 
92 enum COINIT {
93 	COINIT_APARTMENTTHREADED = 2,
94 	COINIT_MULTITHREADED     = 0,
95 	COINIT_DISABLE_OLE1DDE   = 4,
96 	COINIT_SPEED_OVER_MEMORY = 8
97 }
98 
99 enum STDMSHLFLAGS {
100 	SMEXF_SERVER  = 1,
101 	SMEXF_HANDLER
102 }
103 
104 extern(Windows) {
105 	alias HRESULT function(REFCLSID, REFIID, PVOID*) LPFNGETCLASSOBJECT;
106 	alias HRESULT function() LPFNCANUNLOADNOW;
107 
108 	DWORD CoBuildVersion();
109 	HRESULT CoInitialize(PVOID);
110 	HRESULT CoInitializeEx(LPVOID, DWORD);
111 	void CoUninitialize();
112 	HRESULT CoGetMalloc(DWORD, LPMALLOC*);
113 	DWORD CoGetCurrentProcess();
114 	HRESULT CoRegisterMallocSpy(LPMALLOCSPY);
115 	HRESULT CoRevokeMallocSpy();
116 	HRESULT CoCreateStandardMalloc(DWORD, IMalloc*);
117 	//#ifdef DBG
118 	ULONG DebugCoGetRpcFault();
119 	void DebugCoSetRpcFault(ULONG);
120 	//#endif
121 	HRESULT CoGetClassObject(REFCLSID, DWORD, COSERVERINFO*, REFIID, PVOID*);
122 	HRESULT CoRegisterClassObject(REFCLSID, LPUNKNOWN, DWORD, DWORD, PDWORD);
123 	HRESULT CoRevokeClassObject(DWORD);
124 	HRESULT CoGetMarshalSizeMax(ULONG*, REFIID, LPUNKNOWN, DWORD, PVOID, DWORD);
125 	HRESULT CoMarshalInterface(LPSTREAM, REFIID, LPUNKNOWN, DWORD, PVOID, DWORD);
126 	HRESULT CoUnmarshalInterface(LPSTREAM, REFIID, PVOID*);
127 	HRESULT CoMarshalHresult(LPSTREAM, HRESULT);
128 	HRESULT CoUnmarshalHresult(LPSTREAM, HRESULT*);
129 	HRESULT CoReleaseMarshalData(LPSTREAM);
130 	HRESULT CoDisconnectObject(LPUNKNOWN, DWORD);
131 	HRESULT CoLockObjectExternal(LPUNKNOWN, BOOL, BOOL);
132 	HRESULT CoGetStandardMarshal(REFIID, LPUNKNOWN, DWORD, PVOID, DWORD, LPMARSHAL*);
133 	HRESULT CoGetStdMarshalEx(LPUNKNOWN, DWORD, LPUNKNOWN*);
134 	BOOL CoIsHandlerConnected(LPUNKNOWN);
135 	BOOL CoHasStrongExternalConnections(LPUNKNOWN);
136 	HRESULT CoMarshalInterThreadInterfaceInStream(REFIID, LPUNKNOWN, LPSTREAM*);
137 	HRESULT CoGetInterfaceAndReleaseStream(LPSTREAM, REFIID, PVOID*);
138 	HRESULT CoCreateFreeThreadedMarshaler(LPUNKNOWN, LPUNKNOWN*);
139 	HINSTANCE CoLoadLibrary(LPOLESTR, BOOL);
140 	void CoFreeLibrary(HINSTANCE);
141 	void CoFreeAllLibraries();
142 	void CoFreeUnusedLibraries();
143 	HRESULT CoCreateInstance(REFCLSID, LPUNKNOWN, DWORD, REFIID, PVOID*);
144 	HRESULT CoCreateInstanceEx(REFCLSID, IUnknown, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
145 	HRESULT StringFromCLSID(REFCLSID, LPOLESTR*);
146 	HRESULT CLSIDFromString(LPOLESTR, LPCLSID);
147 	HRESULT StringFromIID(REFIID, LPOLESTR*);
148 	HRESULT IIDFromString(LPOLESTR, LPIID);
149 	BOOL CoIsOle1Class(REFCLSID);
150 	HRESULT ProgIDFromCLSID(REFCLSID, LPOLESTR*);
151 	HRESULT CLSIDFromProgID(LPCOLESTR, LPCLSID);
152 	int StringFromGUID2(REFGUID, LPOLESTR, int);
153 	HRESULT CoCreateGuid(GUID*);
154 	BOOL CoFileTimeToDosDateTime(FILETIME*, LPWORD, LPWORD);
155 	BOOL CoDosDateTimeToFileTime(WORD, WORD, FILETIME*);
156 	HRESULT CoFileTimeNow(FILETIME*);
157 	HRESULT CoRegisterMessageFilter(LPMESSAGEFILTER, LPMESSAGEFILTER*);
158 	HRESULT CoGetTreatAsClass(REFCLSID, LPCLSID);
159 	HRESULT CoTreatAsClass(REFCLSID, REFCLSID);
160 	HRESULT DllGetClassObject(REFCLSID, REFIID, PVOID*);
161 	HRESULT DllCanUnloadNow();
162 	PVOID CoTaskMemAlloc(ULONG);
163 	PVOID CoTaskMemRealloc(PVOID, ULONG);
164 	void CoTaskMemFree(PVOID);
165 	HRESULT CreateDataAdviseHolder(LPDATAADVISEHOLDER*);
166 	HRESULT CreateDataCache(LPUNKNOWN, REFCLSID, REFIID, PVOID*);
167 	HRESULT StgCreateDocfile(const(OLECHAR)*, DWORD, DWORD, IStorage*);
168 	HRESULT StgCreateDocfileOnILockBytes(ILockBytes, DWORD, DWORD, IStorage*);
169 	HRESULT StgOpenStorage(const(OLECHAR)*, IStorage, DWORD, SNB, DWORD, IStorage*);
170 	HRESULT StgOpenStorageOnILockBytes(ILockBytes, IStorage, DWORD, SNB, DWORD, IStorage*);
171 	HRESULT StgIsStorageFile(const(OLECHAR)*);
172 	HRESULT StgIsStorageILockBytes(ILockBytes);
173 	HRESULT StgSetTimes(OLECHAR *, FILETIME *, FILETIME *, FILETIME *);
174 	HRESULT StgCreateStorageEx(const(WCHAR)*, DWORD, DWORD, DWORD, STGOPTIONS*, void*, REFIID, void**);
175 	HRESULT StgOpenStorageEx(const(WCHAR)*, DWORD, DWORD, DWORD, STGOPTIONS*, void*, REFIID, void**);
176 	HRESULT BindMoniker(LPMONIKER, DWORD, REFIID, PVOID*);
177 	HRESULT CoGetObject(LPCWSTR, BIND_OPTS*, REFIID, void**);
178 	HRESULT MkParseDisplayName(LPBC, LPCOLESTR, ULONG*, LPMONIKER*);
179 	HRESULT MonikerRelativePathTo(LPMONIKER, LPMONIKER, LPMONIKER*, BOOL);
180 	HRESULT MonikerCommonPrefixWith(LPMONIKER, LPMONIKER, LPMONIKER*);
181 	HRESULT CreateBindCtx(DWORD, LPBC*);
182 	HRESULT CreateGenericComposite(LPMONIKER, LPMONIKER, LPMONIKER*);
183 	HRESULT GetClassFile (LPCOLESTR, CLSID*);
184 	HRESULT CreateFileMoniker(LPCOLESTR, LPMONIKER*);
185 	HRESULT CreateItemMoniker(LPCOLESTR, LPCOLESTR, LPMONIKER*);
186 	HRESULT CreateAntiMoniker(LPMONIKER*);
187 	HRESULT CreatePointerMoniker(LPUNKNOWN, LPMONIKER*);
188 	HRESULT GetRunningObjectTable(DWORD, LPRUNNINGOBJECTTABLE*);
189 	HRESULT CoInitializeSecurity(PSECURITY_DESCRIPTOR, LONG, SOLE_AUTHENTICATION_SERVICE*, void*, DWORD, DWORD, void*, DWORD, void*);
190 	HRESULT CoGetCallContext(REFIID, void**);
191 	HRESULT CoQueryProxyBlanket(IUnknown*, DWORD*, DWORD*, OLECHAR**, DWORD*, DWORD*, RPC_AUTH_IDENTITY_HANDLE*, DWORD*);
192 	HRESULT CoSetProxyBlanket(IUnknown*, DWORD, DWORD, OLECHAR*, DWORD, DWORD, RPC_AUTH_IDENTITY_HANDLE, DWORD);
193 	HRESULT CoCopyProxy(IUnknown*, IUnknown**);
194 	HRESULT CoQueryClientBlanket(DWORD*, DWORD*, OLECHAR**, DWORD*, DWORD*, RPC_AUTHZ_HANDLE*, DWORD*);
195 	HRESULT CoImpersonateClient();
196 	HRESULT CoRevertToSelf();
197 	HRESULT CoQueryAuthenticationServices(DWORD*, SOLE_AUTHENTICATION_SERVICE**);
198 	HRESULT CoSwitchCallContext(IUnknown*, IUnknown**);
199 	HRESULT CoGetInstanceFromFile(COSERVERINFO*, CLSID*, IUnknown*, DWORD, DWORD, OLECHAR*, DWORD, MULTI_QI*);
200 	HRESULT CoGetInstanceFromIStorage(COSERVERINFO*, CLSID*, IUnknown*, DWORD, IStorage*, DWORD, MULTI_QI*);
201 	ULONG CoAddRefServerProcess();
202 	ULONG CoReleaseServerProcess();
203 	HRESULT CoResumeClassObjects();
204 	HRESULT CoSuspendClassObjects();
205 	HRESULT CoGetPSClsid(REFIID, CLSID*);
206 	HRESULT CoRegisterPSClsid(REFIID, REFCLSID);
207 }