Mercurial > projects > dwt-win
annotate dwt/ole/win32/OLE.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 619faee45ef6 |
children |
rev | line source |
---|---|
97 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
98 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
97 | 12 *******************************************************************************/ |
13 module dwt.ole.win32.OLE; | |
14 | |
15 import dwt.dwthelper.File; | |
16 | |
17 import dwt.DWT; | |
18 import dwt.DWTError; | |
19 import dwt.DWTException; | |
20 import dwt.internal.ole.win32.COM; | |
21 import dwt.internal.win32.OS; | |
22 | |
23 import dwt.dwthelper.utils; | |
24 import tango.util.Convert; | |
25 /** | |
26 * | |
27 * OLE contains all the constants used to create an ActiveX Control or an OLE Document. | |
28 * | |
29 * <p>Definitions for these constants can be found in MSDN. | |
30 * | |
31 */ | |
32 public class OLE : DWT { | |
33 | |
34 public static const int S_FALSE = 1; // Used for functions that semantically return a bool FALSE result to indicate that the function succeeded. | |
35 public static const int S_OK = 0; // Function succeeded. | |
36 public static const int E_FAIL = -2147467259; // Unspecified failure. | |
37 public static const int E_INVALIDARG = -2147024809; // Invalid argument | |
38 public static const int E_NOINTERFACE = -2147467262; // QueryInterface did not recognize the requested interface. | |
39 public static const int E_NOTIMPL = -2147467263; // Not implemented | |
40 | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
41 public static const String IID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}"; //$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
42 public static const String IID_IDISPATCH = "{00020400-0000-0000-C000-000000000046}"; //$NON-NLS-1$ |
97 | 43 |
44 // Verbs that can be invoked on this client | |
45 public static const int OLEIVERB_DISCARDUNDOSTATE = -6; // close the OLE object and discard the undo state | |
46 public static const int OLEIVERB_HIDE = -3; // hide the OLE object | |
47 public static const int OLEIVERB_INPLACEACTIVATE = -5; // open the OLE for editing in-place | |
48 public static const int OLEIVERB_OPEN = -2; // open the OLE object for editing in a separate window | |
49 public static const int OLEIVERB_PRIMARY = 0; // opens the OLE object for editing | |
50 public static const int OLEIVERB_PROPERTIES = -7; // request the OLE object properties dialog | |
51 public static const int OLEIVERB_SHOW = -1; // show the OLE object | |
52 public static const int OLEIVERB_UIACTIVATE = -4; // activate the UI for the OLE object | |
53 | |
54 public static const int PROPERTY_CHANGING = 0; | |
55 public static const int PROPERTY_CHANGED = 1; | |
56 | |
57 /** | |
58 * Error code for OleError - No specific error information available | |
59 */ | |
60 public static const int HRESULT_UNSPECIFIED = 0; | |
61 /** | |
62 * Error code for OleError - Failed to create file | |
63 */ | |
64 public static const int ERROR_CANNOT_CREATE_FILE = 1000; | |
65 /** | |
66 * Error code for OleError - Failed to create Ole Client | |
67 */ | |
68 public static const int ERROR_CANNOT_CREATE_OBJECT = 1001; | |
69 /** | |
70 * Error code for OleError - File does not exist, is not accessible to user or does not have the correct format | |
71 */ | |
72 public static const int ERROR_CANNOT_OPEN_FILE = 1002; | |
73 /** | |
74 * Error code for OleError - Failed to find requested interface on OLE Object | |
75 */ | |
76 public static const int ERROR_INTERFACE_NOT_FOUND = 1003; | |
77 /** | |
78 * Error code for OleError - Class ID not found in registry | |
79 */ | |
80 public static const int ERROR_INVALID_CLASSID = 1004; | |
81 /** | |
82 * Error code for OleError - Failed to get the class factory for the specified classID | |
83 */ | |
84 public static const int ERROR_CANNOT_ACCESS_CLASSFACTORY = 1005; | |
85 /** | |
86 * Error code for OleError - Failed to create Licensed instance | |
87 */ | |
88 public static const int ERROR_CANNOT_CREATE_LICENSED_OBJECT = 1006; | |
89 /** | |
90 * Error code for OleError - Out of Memory | |
91 */ | |
92 public static const int ERROR_OUT_OF_MEMORY = 1007; | |
93 /** | |
94 * Error code for OleError - Failed to change Variant type | |
95 */ | |
96 public static const int ERROR_CANNOT_CHANGE_VARIANT_TYPE = 1010; | |
97 /** | |
98 * Error code for OleError - Invalid address received for Ole Interface | |
99 */ | |
100 public static const int ERROR_INVALID_INTERFACE_ADDRESS = 1011; | |
101 /** | |
102 * Error code for OleError - Unable to find Application | |
103 */ | |
104 public static const int ERROR_APPLICATION_NOT_FOUND = 1013; | |
105 /** | |
106 * Error code for OleError - Action can not be performed | |
107 */ | |
108 public static const int ERROR_ACTION_NOT_PERFORMED = 1014; | |
109 | |
110 public static const int OLECMDF_SUPPORTED = 1; | |
111 public static const int OLECMDF_ENABLED = 2; | |
112 public static const int OLECMDF_LATCHED = 4; | |
113 public static const int OLECMDF_NINCHED = 8; | |
114 | |
115 public static const int OLECMDTEXTF_NONE = 0; | |
116 public static const int OLECMDTEXTF_NAME = 1; | |
117 public static const int OLECMDTEXTF_STATUS = 2; | |
118 | |
119 public static const int OLECMDEXECOPT_DODEFAULT = 0; | |
120 public static const int OLECMDEXECOPT_PROMPTUSER = 1; | |
121 public static const int OLECMDEXECOPT_DONTPROMPTUSER = 2; | |
122 public static const int OLECMDEXECOPT_SHOWHELP = 3; | |
123 | |
124 public static const int OLECMDID_OPEN = 1; | |
125 public static const int OLECMDID_NEW = 2; | |
126 public static const int OLECMDID_SAVE = 3; | |
127 public static const int OLECMDID_SAVEAS = 4; | |
128 public static const int OLECMDID_SAVECOPYAS = 5; | |
129 public static const int OLECMDID_PRINT = 6; | |
130 public static const int OLECMDID_PRINTPREVIEW = 7; | |
131 public static const int OLECMDID_PAGESETUP = 8; | |
132 public static const int OLECMDID_SPELL = 9; | |
133 public static const int OLECMDID_PROPERTIES = 10; | |
134 public static const int OLECMDID_CUT = 11; | |
135 public static const int OLECMDID_COPY = 12; | |
136 public static const int OLECMDID_PASTE = 13; | |
137 public static const int OLECMDID_PASTESPECIAL = 14; | |
138 public static const int OLECMDID_UNDO = 15; | |
139 public static const int OLECMDID_REDO = 16; | |
140 public static const int OLECMDID_SELECTALL = 17; | |
141 public static const int OLECMDID_CLEARSELECTION = 18; | |
142 public static const int OLECMDID_ZOOM = 19; | |
143 public static const int OLECMDID_GETZOOMRANGE = 20; | |
144 public static const int OLECMDID_UPDATECOMMANDS = 21; | |
145 public static const int OLECMDID_REFRESH = 22; | |
146 public static const int OLECMDID_STOP = 23; | |
147 public static const int OLECMDID_HIDETOOLBARS = 24; | |
148 public static const int OLECMDID_SETPROGRESSMAX = 25; | |
149 public static const int OLECMDID_SETPROGRESSPOS = 26; | |
150 public static const int OLECMDID_SETPROGRESSTEXT = 27; | |
151 public static const int OLECMDID_SETTITLE = 28; | |
152 public static const int OLECMDID_SETDOWNLOADSTATE = 29; | |
153 public static const int OLECMDID_STOPDOWNLOAD = 30; | |
154 | |
155 /* Ole Property Description flags */ | |
156 public static int VARFLAG_FREADONLY = 0x1; | |
157 public static int VARFLAG_FSOURCE = 0x2; | |
158 public static int VARFLAG_FBINDABLE = 0x4; | |
159 public static int VARFLAG_FREQUESTEDIT = 0x8; | |
160 public static int VARFLAG_FDISPLAYBIND = 0x10; | |
161 public static int VARFLAG_FDEFAULTBIND = 0x20; | |
162 public static int VARFLAG_FHIDDEN = 0x40; | |
163 public static int VARFLAG_FRESTRICTED = 0x80; | |
164 public static int VARFLAG_FDEFAULTCOLLELEM = 0x100; | |
165 public static int VARFLAG_FUIDEFAULT = 0x200; | |
166 public static int VARFLAG_FNONBROWSABLE = 0x400; | |
167 public static int VARFLAG_FREPLACEABLE = 0x800; | |
168 public static int VARFLAG_FIMMEDIATEBIND = 0x1000; | |
169 | |
170 /* Ole Property Description kind */ | |
171 public static int VAR_PERINSTANCE = 0; | |
172 public static int VAR_STATIC = 1; | |
173 public static int VAR_CONST = 2; | |
174 public static int VAR_DISPATCH = 3; | |
175 | |
176 /* Ole Parameter Description flags */ | |
177 public static short IDLFLAG_NONE = 0; | |
178 public static short IDLFLAG_FIN = 1; | |
179 public static short IDLFLAG_FOUT = 2; | |
180 public static short IDLFLAG_FLCID = 4; | |
181 public static short IDLFLAG_FRETVAL = 8; | |
182 | |
183 /* Ole Description types */ | |
184 public static const short VT_BOOL = 11; // bool; True=-1, False=0. | |
185 public static const short VT_BSTR = 8; // Binary String. | |
186 public static const short VT_BYREF = 16384; // By reference - must be combined with one of the other VT values | |
187 public static const short VT_CY = 6; // Currency. | |
188 public static const short VT_DATE = 7; // Date. | |
189 public static const short VT_DISPATCH = 9; // IDispatch | |
190 public static const short VT_EMPTY = 0; // Not specified. | |
191 public static const short VT_ERROR = 10; // Scodes. | |
192 public static const short VT_I2 = 2; // 2-byte signed int. | |
193 public static const short VT_I4 = 3; // 4-byte signed int. | |
194 public static const short VT_NULL = 1; // Null. | |
195 public static const short VT_R4 = 4; // 4-byte real. | |
196 public static const short VT_R8 = 5; // 8-byte real. | |
197 public static const short VT_UI1 = 17; // Unsigned char. | |
198 public static const short VT_UI4 = 19; // Unsigned int. | |
199 public static const short VT_UNKNOWN = 13; // IUnknown FAR*. | |
200 public static const short VT_VARIANT = 12; // VARIANT FAR*. | |
201 public static const short VT_PTR = 26; | |
202 public static const short VT_USERDEFINED = 29; | |
203 public static const short VT_HRESULT = 25; | |
204 public static const short VT_DECIMAL = 14; | |
205 public static const short VT_I1 = 16; | |
206 public static const short VT_UI2 = 18; | |
207 public static const short VT_I8 = 20; | |
208 public static const short VT_UI8 = 21; | |
209 public static const short VT_INT = 22; | |
210 public static const short VT_UINT = 23; | |
211 public static const short VT_VOID = 24; | |
212 public static const short VT_SAFEARRAY = 27; | |
213 public static const short VT_CARRAY = 28; | |
214 public static const short VT_LPSTR = 30; | |
215 public static const short VT_LPWSTR = 31; | |
216 public static const short VT_RECORD = 36; | |
217 public static const short VT_FILETIME = 64; | |
218 public static const short VT_BLOB = 65; | |
219 public static const short VT_STREAM = 66; | |
220 public static const short VT_STORAGE = 67; | |
221 public static const short VT_STREAMED_OBJECT = 68; | |
222 public static const short VT_STORED_OBJECT = 69; | |
223 public static const short VT_BLOB_OBJECT = 70; | |
224 public static const short VT_CF = 71; | |
225 public static const short VT_CLSID = 72; | |
226 public static const short VT_VERSIONED_STREAM = 73; | |
227 public static const short VT_BSTR_BLOB = 0xfff; | |
228 public static const short VT_VECTOR = 0x1000; | |
229 public static const short VT_ARRAY = 0x2000; | |
230 | |
231 /* Ole Function Description Invoke Kind values */ | |
232 public static const int INVOKE_FUNC = 1; | |
233 public static const int INVOKE_PROPERTYGET = 2; | |
234 public static const int INVOKE_PROPERTYPUT = 4; | |
235 public static const int INVOKE_PROPERTYPUTREF = 8; | |
236 | |
237 /* Ole Function Description function kind */ | |
238 public static const int FUNC_VIRTUAL = 0; | |
239 public static const int FUNC_PUREVIRTUAL = 1; | |
240 public static const int FUNC_NONVIRTUAL = 2; | |
241 public static const int FUNC_STATIC = 3; | |
242 public static const int FUNC_DISPATCH = 4; | |
243 | |
244 /* Ole Function Description function flags */ | |
245 public static const short FUNCFLAG_FRESTRICTED = 1; | |
246 public static const short FUNCFLAG_FSOURCE = 0x2; | |
247 public static const short FUNCFLAG_FBINDABLE = 0x4; | |
248 public static const short FUNCFLAG_FREQUESTEDIT = 0x8; | |
249 public static const short FUNCFLAG_FDISPLAYBIND = 0x10; | |
250 public static const short FUNCFLAG_FDEFAULTBIND = 0x20; | |
251 public static const short FUNCFLAG_FHIDDEN = 0x40; | |
252 public static const short FUNCFLAG_FUSESGETLASTERROR = 0x80; | |
253 public static const short FUNCFLAG_FDEFAULTCOLLELEM = 0x100; | |
254 public static const short FUNCFLAG_FUIDEFAULT = 0x200; | |
255 public static const short FUNCFLAG_FNONBROWSABLE = 0x400; | |
256 public static const short FUNCFLAG_FREPLACEABLE = 0x800; | |
257 public static const short FUNCFLAG_FIMMEDIATEBIND = 0x1000; | |
258 | |
259 /* Ole Function Description calling convention */ | |
260 public static const int CC_FASTCALL = 0; | |
261 public static const int CC_CDECL = 1; | |
262 public static const int CC_MSCPASCAL = 2; | |
263 public static const int CC_PASCAL = 2; | |
264 public static const int CC_MACPASCAL = 3; | |
265 public static const int CC_STDCALL = 4; | |
266 public static const int CC_FPFASTCALL = 5; | |
267 public static const int CC_SYSCALL = 6; | |
268 public static const int CC_MPWCDECL = 7; | |
269 public static const int CC_MPWPASCAL = 8; | |
270 public static const int CC_MAX = 9; | |
271 | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
272 static const String ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported.";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
273 static const String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
274 static const String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
275 static const String ERROR_CANNOT_OPEN_FILE_MSG = "File does not exist, is not accessible to user or does not have the correct format.";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
276 static const String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
277 static const String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
278 static const String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
279 static const String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
280 static const String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
281 static const String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
282 static const String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
283 static const String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
284 static const String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$ |
97 | 285 |
286 | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
287 public static void error (String file, long line, int code) { |
98 | 288 error (code, 0); |
289 } | |
97 | 290 public static void error (int code) { |
291 error (code, 0); | |
292 } | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
293 public static void error (String file, long line, int code, int hresult) { |
98 | 294 error (code, hresult); |
295 } | |
97 | 296 public static void error (int code, int hresult) { |
297 | |
298 switch (code) { | |
299 /* Illegal Arguments (non-fatal) */ | |
300 case ERROR_INVALID_INTERFACE_ADDRESS :{ | |
301 throw new IllegalArgumentException (ERROR_INVALID_INTERFACE_ADDRESS_MSG); | |
302 } | |
303 | |
304 /* DWT Errors (non-fatal) */ | |
305 case ERROR_CANNOT_CREATE_FILE : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
306 String msg = ERROR_CANNOT_CREATE_FILE_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
307 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 308 throw new DWTException (code, msg); |
309 } | |
310 case ERROR_CANNOT_CREATE_OBJECT : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
311 String msg = ERROR_CANNOT_CREATE_OBJECT_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
312 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 313 throw new DWTException (code, msg);//$NON-NLS-1$ |
314 } | |
315 case ERROR_CANNOT_OPEN_FILE : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
316 String msg = ERROR_CANNOT_OPEN_FILE_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
317 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 318 throw new DWTException (code, msg); |
319 } | |
320 case ERROR_INTERFACE_NOT_FOUND : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
321 String msg = ERROR_INTERFACE_NOT_FOUND_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
322 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 323 throw new DWTException (code, msg); |
324 } | |
325 case ERROR_INVALID_CLASSID : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
326 String msg = ERROR_INVALID_CLASSID_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
327 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 328 throw new DWTException (code, msg); |
329 } | |
330 case ERROR_CANNOT_ACCESS_CLASSFACTORY : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
331 String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
332 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 333 throw new DWTException (code, msg); |
334 } | |
335 case ERROR_CANNOT_CREATE_LICENSED_OBJECT : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
336 String msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
337 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 338 throw new DWTException (code, msg); |
339 } | |
340 case ERROR_CANNOT_CHANGE_VARIANT_TYPE : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
341 String msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
342 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 343 throw new DWTException (code, msg); |
344 } | |
345 case ERROR_APPLICATION_NOT_FOUND : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
346 String msg = ERROR_APPLICATION_NOT_FOUND_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
347 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 348 throw new DWTException (code, msg); |
349 } | |
350 case ERROR_ACTION_NOT_PERFORMED : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
351 String msg = ERROR_ACTION_NOT_PERFORMED_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
352 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$ |
97 | 353 throw new DWTException (code, msg); |
354 } | |
355 | |
356 /* OS Failure/Limit (fatal, may occur only on some platforms) */ | |
357 case ERROR_OUT_OF_MEMORY : { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
358 String msg = ERROR_ACTION_NOT_PERFORMED_MSG; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
359 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult); //$NON-NLS-1$ |
97 | 360 throw new DWTError (code, msg); |
361 } | |
162
619faee45ef6
add missing default cases
Thomas Graber <d4rkdragon@gmail.com>
parents:
98
diff
changeset
|
362 default: |
97 | 363 } |
364 | |
365 /* Unknown/Undefined Error */ | |
366 DWT.error(code); | |
367 } | |
368 | |
369 /* | |
370 * Finds the OLE program id that is associated with an extension. | |
371 * The extension may or may not begin with a '.'. On platforms | |
372 * that do not support OLE, an empty string is returned. | |
373 * | |
374 * @param extension the program extension | |
375 * @return a string that is the OLE program id or an empty string | |
376 * | |
377 * @exception IllegalArgumentException <ul> | |
378 * <li>ERROR_NULL_ARGUMENT when extension is null</li> | |
379 * </ul> | |
380 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
381 public static String findProgramID (String extension) { |
97 | 382 if (extension is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
383 if (extension.length is 0) return ""; //$NON-NLS-1$ | |
384 | |
385 if (extension.charAt (0) !is '.') extension = "." ~ extension; //$NON-NLS-1$ | |
386 | |
387 /* Use the character encoding for the default locale */ | |
388 TCHAR[] extensionKey = StrToTCHARs(0, extension, true); | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
389 String result = getKeyValue(extensionKey); |
97 | 390 if (result !is null) { |
391 // look for "<programID>\NotInsertable" | |
392 TCHAR[] notInsertableKey = StrToTCHARs(0, result~"\\NotInsertable", true); //$NON-NLS-1$ | |
393 if (getKeyExists(notInsertableKey)) return ""; //$NON-NLS-1$ | |
394 // look for "<programID>\Insertable" | |
395 TCHAR[] insertableKey = StrToTCHARs(0, result~"\\Insertable", true); //$NON-NLS-1$ | |
396 if (getKeyExists(insertableKey)) return result; | |
397 // look for "<programID>\protocol\StdFileEditing\server" | |
398 TCHAR[] serverKey = StrToTCHARs(0, result~"\\protocol\\StdFileEditing\\server", true); //$NON-NLS-1$ | |
399 if (getKeyExists(serverKey)) return result; | |
400 } | |
401 | |
402 return ""; //$NON-NLS-1$ | |
403 } | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
404 static String getKeyValue (TCHAR[] key) { |
97 | 405 void* [1] phkResult; |
406 if (OS.RegOpenKeyEx (cast(void*)OS.HKEY_CLASSES_ROOT, key.ptr, 0, OS.KEY_READ, phkResult.ptr) !is 0) { | |
407 return null; | |
408 } | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
409 String result = null; |
97 | 410 uint [1] lpcbData; |
411 if (OS.RegQueryValueEx (phkResult [0], null, null, null, null, lpcbData.ptr) is 0) { | |
412 int length_ = lpcbData [0] / TCHAR.sizeof; | |
413 if (length_ is 0) { | |
414 result = ""; | |
415 } else { | |
416 /* Use the character encoding for the default locale */ | |
417 TCHAR[] lpData = NewTCHARs (0, length_); | |
418 if (OS.RegQueryValueEx (phkResult [0], null, null, null, cast(ubyte*)lpData.ptr, lpcbData.ptr) is 0) { | |
419 length_ = Math.max(0, lpData.length - 1); | |
420 result = TCHARsToStr( lpData[ 0 .. length_ ] ); | |
421 } | |
422 } | |
423 } | |
424 if (phkResult [0] !is null) OS.RegCloseKey (phkResult [0]); | |
425 return result; | |
426 } | |
427 private static bool getKeyExists (TCHAR[] key) { | |
428 void* [1] phkResult; | |
429 if (OS.RegOpenKeyEx (cast(void*)OS.HKEY_CLASSES_ROOT, key.ptr, 0, OS.KEY_READ, phkResult.ptr) !is 0) { | |
430 return false; | |
431 } | |
432 if (phkResult [0] !is null) OS.RegCloseKey (phkResult [0]); | |
433 return true; | |
434 } | |
435 /** | |
436 * Returns true if the specified file has an OLE Storage format. | |
437 * | |
438 * Note all empty files (regardless of extension) will return false. | |
439 * | |
440 * @param file the file to be checked | |
441 * | |
442 * @return true if this file has an OLE Storage format | |
443 */ | |
444 public static bool isOleFile(File file) { | |
445 if (file is null || !file.exists() || file.isDirectory()) | |
446 return false; | |
447 | |
448 return (COM.StgIsStorageFile( StrToTCHARz(file.getAbsolutePath()~"\0")) is COM.S_OK); | |
449 } | |
450 | |
451 } |