comparison 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
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
36 public static const int E_FAIL = -2147467259; // Unspecified failure. 36 public static const int E_FAIL = -2147467259; // Unspecified failure.
37 public static const int E_INVALIDARG = -2147024809; // Invalid argument 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. 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 39 public static const int E_NOTIMPL = -2147467263; // Not implemented
40 40
41 public static const char[] IID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}"; //$NON-NLS-1$ 41 public static const String IID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}"; //$NON-NLS-1$
42 public static const char[] IID_IDISPATCH = "{00020400-0000-0000-C000-000000000046}"; //$NON-NLS-1$ 42 public static const String IID_IDISPATCH = "{00020400-0000-0000-C000-000000000046}"; //$NON-NLS-1$
43 43
44 // Verbs that can be invoked on this client 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 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 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 47 public static const int OLEIVERB_INPLACEACTIVATE = -5; // open the OLE for editing in-place
267 public static const int CC_SYSCALL = 6; 267 public static const int CC_SYSCALL = 6;
268 public static const int CC_MPWCDECL = 7; 268 public static const int CC_MPWCDECL = 7;
269 public static const int CC_MPWPASCAL = 8; 269 public static const int CC_MPWPASCAL = 8;
270 public static const int CC_MAX = 9; 270 public static const int CC_MAX = 9;
271 271
272 static const char[] ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported.";//$NON-NLS-1$ 272 static const String ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported.";//$NON-NLS-1$
273 static const char[] ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$ 273 static const String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$
274 static const char[] ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$ 274 static const String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$
275 static const char[] ERROR_CANNOT_OPEN_FILE_MSG = "File does not exist, is not accessible to user or does not have the correct format.";//$NON-NLS-1$ 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$
276 static const char[] ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$ 276 static const String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$
277 static const char[] ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$ 277 static const String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$
278 static const char[] ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$ 278 static const String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$
279 static const char[] ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$ 279 static const String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$
280 static const char[] ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$ 280 static const String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$
281 static const char[] ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$ 281 static const String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$
282 static const char[] ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$ 282 static const String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$
283 static const char[] ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$ 283 static const String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$
284 static const char[] ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$ 284 static const String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$
285 285
286 286
287 public static void error (char[] file, long line, int code) { 287 public static void error (String file, long line, int code) {
288 error (code, 0); 288 error (code, 0);
289 } 289 }
290 public static void error (int code) { 290 public static void error (int code) {
291 error (code, 0); 291 error (code, 0);
292 } 292 }
293 public static void error (char[] file, long line, int code, int hresult) { 293 public static void error (String file, long line, int code, int hresult) {
294 error (code, hresult); 294 error (code, hresult);
295 } 295 }
296 public static void error (int code, int hresult) { 296 public static void error (int code, int hresult) {
297 297
298 switch (code) { 298 switch (code) {
301 throw new IllegalArgumentException (ERROR_INVALID_INTERFACE_ADDRESS_MSG); 301 throw new IllegalArgumentException (ERROR_INVALID_INTERFACE_ADDRESS_MSG);
302 } 302 }
303 303
304 /* DWT Errors (non-fatal) */ 304 /* DWT Errors (non-fatal) */
305 case ERROR_CANNOT_CREATE_FILE : { 305 case ERROR_CANNOT_CREATE_FILE : {
306 char[] msg = ERROR_CANNOT_CREATE_FILE_MSG; 306 String msg = ERROR_CANNOT_CREATE_FILE_MSG;
307 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 307 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
308 throw new DWTException (code, msg); 308 throw new DWTException (code, msg);
309 } 309 }
310 case ERROR_CANNOT_CREATE_OBJECT : { 310 case ERROR_CANNOT_CREATE_OBJECT : {
311 char[] msg = ERROR_CANNOT_CREATE_OBJECT_MSG; 311 String msg = ERROR_CANNOT_CREATE_OBJECT_MSG;
312 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 312 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
313 throw new DWTException (code, msg);//$NON-NLS-1$ 313 throw new DWTException (code, msg);//$NON-NLS-1$
314 } 314 }
315 case ERROR_CANNOT_OPEN_FILE : { 315 case ERROR_CANNOT_OPEN_FILE : {
316 char[] msg = ERROR_CANNOT_OPEN_FILE_MSG; 316 String msg = ERROR_CANNOT_OPEN_FILE_MSG;
317 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 317 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
318 throw new DWTException (code, msg); 318 throw new DWTException (code, msg);
319 } 319 }
320 case ERROR_INTERFACE_NOT_FOUND : { 320 case ERROR_INTERFACE_NOT_FOUND : {
321 char[] msg = ERROR_INTERFACE_NOT_FOUND_MSG; 321 String msg = ERROR_INTERFACE_NOT_FOUND_MSG;
322 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 322 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
323 throw new DWTException (code, msg); 323 throw new DWTException (code, msg);
324 } 324 }
325 case ERROR_INVALID_CLASSID : { 325 case ERROR_INVALID_CLASSID : {
326 char[] msg = ERROR_INVALID_CLASSID_MSG; 326 String msg = ERROR_INVALID_CLASSID_MSG;
327 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 327 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
328 throw new DWTException (code, msg); 328 throw new DWTException (code, msg);
329 } 329 }
330 case ERROR_CANNOT_ACCESS_CLASSFACTORY : { 330 case ERROR_CANNOT_ACCESS_CLASSFACTORY : {
331 char[] msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG; 331 String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG;
332 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 332 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
333 throw new DWTException (code, msg); 333 throw new DWTException (code, msg);
334 } 334 }
335 case ERROR_CANNOT_CREATE_LICENSED_OBJECT : { 335 case ERROR_CANNOT_CREATE_LICENSED_OBJECT : {
336 char[] msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG; 336 String msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG;
337 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 337 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
338 throw new DWTException (code, msg); 338 throw new DWTException (code, msg);
339 } 339 }
340 case ERROR_CANNOT_CHANGE_VARIANT_TYPE : { 340 case ERROR_CANNOT_CHANGE_VARIANT_TYPE : {
341 char[] msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG; 341 String msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG;
342 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 342 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
343 throw new DWTException (code, msg); 343 throw new DWTException (code, msg);
344 } 344 }
345 case ERROR_APPLICATION_NOT_FOUND : { 345 case ERROR_APPLICATION_NOT_FOUND : {
346 char[] msg = ERROR_APPLICATION_NOT_FOUND_MSG; 346 String msg = ERROR_APPLICATION_NOT_FOUND_MSG;
347 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 347 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
348 throw new DWTException (code, msg); 348 throw new DWTException (code, msg);
349 } 349 }
350 case ERROR_ACTION_NOT_PERFORMED : { 350 case ERROR_ACTION_NOT_PERFORMED : {
351 char[] msg = ERROR_ACTION_NOT_PERFORMED_MSG; 351 String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
352 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ 352 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult);//$NON-NLS-1$
353 throw new DWTException (code, msg); 353 throw new DWTException (code, msg);
354 } 354 }
355 355
356 /* OS Failure/Limit (fatal, may occur only on some platforms) */ 356 /* OS Failure/Limit (fatal, may occur only on some platforms) */
357 case ERROR_OUT_OF_MEMORY : { 357 case ERROR_OUT_OF_MEMORY : {
358 char[] msg = ERROR_ACTION_NOT_PERFORMED_MSG; 358 String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
359 if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult); //$NON-NLS-1$ 359 if (hresult !is 0) msg ~= " result = "~to!(String)(hresult); //$NON-NLS-1$
360 throw new DWTError (code, msg); 360 throw new DWTError (code, msg);
361 } 361 }
362 default: 362 default:
363 } 363 }
364 364
376 * 376 *
377 * @exception IllegalArgumentException <ul> 377 * @exception IllegalArgumentException <ul>
378 * <li>ERROR_NULL_ARGUMENT when extension is null</li> 378 * <li>ERROR_NULL_ARGUMENT when extension is null</li>
379 * </ul> 379 * </ul>
380 */ 380 */
381 public static char[] findProgramID (char[] extension) { 381 public static String findProgramID (String extension) {
382 if (extension is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 382 if (extension is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
383 if (extension.length is 0) return ""; //$NON-NLS-1$ 383 if (extension.length is 0) return ""; //$NON-NLS-1$
384 384
385 if (extension.charAt (0) !is '.') extension = "." ~ extension; //$NON-NLS-1$ 385 if (extension.charAt (0) !is '.') extension = "." ~ extension; //$NON-NLS-1$
386 386
387 /* Use the character encoding for the default locale */ 387 /* Use the character encoding for the default locale */
388 TCHAR[] extensionKey = StrToTCHARs(0, extension, true); 388 TCHAR[] extensionKey = StrToTCHARs(0, extension, true);
389 char[] result = getKeyValue(extensionKey); 389 String result = getKeyValue(extensionKey);
390 if (result !is null) { 390 if (result !is null) {
391 // look for "<programID>\NotInsertable" 391 // look for "<programID>\NotInsertable"
392 TCHAR[] notInsertableKey = StrToTCHARs(0, result~"\\NotInsertable", true); //$NON-NLS-1$ 392 TCHAR[] notInsertableKey = StrToTCHARs(0, result~"\\NotInsertable", true); //$NON-NLS-1$
393 if (getKeyExists(notInsertableKey)) return ""; //$NON-NLS-1$ 393 if (getKeyExists(notInsertableKey)) return ""; //$NON-NLS-1$
394 // look for "<programID>\Insertable" 394 // look for "<programID>\Insertable"
399 if (getKeyExists(serverKey)) return result; 399 if (getKeyExists(serverKey)) return result;
400 } 400 }
401 401
402 return ""; //$NON-NLS-1$ 402 return ""; //$NON-NLS-1$
403 } 403 }
404 static char[] getKeyValue (TCHAR[] key) { 404 static String getKeyValue (TCHAR[] key) {
405 void* [1] phkResult; 405 void* [1] phkResult;
406 if (OS.RegOpenKeyEx (cast(void*)OS.HKEY_CLASSES_ROOT, key.ptr, 0, OS.KEY_READ, phkResult.ptr) !is 0) { 406 if (OS.RegOpenKeyEx (cast(void*)OS.HKEY_CLASSES_ROOT, key.ptr, 0, OS.KEY_READ, phkResult.ptr) !is 0) {
407 return null; 407 return null;
408 } 408 }
409 char[] result = null; 409 String result = null;
410 uint [1] lpcbData; 410 uint [1] lpcbData;
411 if (OS.RegQueryValueEx (phkResult [0], null, null, null, null, lpcbData.ptr) is 0) { 411 if (OS.RegQueryValueEx (phkResult [0], null, null, null, null, lpcbData.ptr) is 0) {
412 int length_ = lpcbData [0] / TCHAR.sizeof; 412 int length_ = lpcbData [0] / TCHAR.sizeof;
413 if (length_ is 0) { 413 if (length_ is 0) {
414 result = ""; 414 result = "";