?? ole.java
字號:
public static final short VT_VERSIONED_STREAM = 73; public static final short VT_BSTR_BLOB = 0xfff; public static final short VT_VECTOR = 0x1000; public static final short VT_ARRAY = 0x2000; /* Ole Function Description Invoke Kind values */ public static final int INVOKE_FUNC = 1; public static final int INVOKE_PROPERTYGET = 2; public static final int INVOKE_PROPERTYPUT = 4; public static final int INVOKE_PROPERTYPUTREF = 8; /* Ole Function Description function kind */ public static final int FUNC_VIRTUAL = 0; public static final int FUNC_PUREVIRTUAL = 1; public static final int FUNC_NONVIRTUAL = 2; public static final int FUNC_STATIC = 3; public static final int FUNC_DISPATCH = 4; /* Ole Function Description function flags */ public static final short FUNCFLAG_FRESTRICTED = 1; public static final short FUNCFLAG_FSOURCE = 0x2; public static final short FUNCFLAG_FBINDABLE = 0x4; public static final short FUNCFLAG_FREQUESTEDIT = 0x8; public static final short FUNCFLAG_FDISPLAYBIND = 0x10; public static final short FUNCFLAG_FDEFAULTBIND = 0x20; public static final short FUNCFLAG_FHIDDEN = 0x40; public static final short FUNCFLAG_FUSESGETLASTERROR = 0x80; public static final short FUNCFLAG_FDEFAULTCOLLELEM = 0x100; public static final short FUNCFLAG_FUIDEFAULT = 0x200; public static final short FUNCFLAG_FNONBROWSABLE = 0x400; public static final short FUNCFLAG_FREPLACEABLE = 0x800; public static final short FUNCFLAG_FIMMEDIATEBIND = 0x1000; /* Ole Function Description calling convention */ public static final int CC_FASTCALL = 0; public static final int CC_CDECL = 1; public static final int CC_MSCPASCAL = 2; public static final int CC_PASCAL = 2; public static final int CC_MACPASCAL = 3; public static final int CC_STDCALL = 4; public static final int CC_FPFASTCALL = 5; public static final int CC_SYSCALL = 6; public static final int CC_MPWCDECL = 7; public static final int CC_MPWPASCAL = 8; public static final int CC_MAX = 9; static final String ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported.";//$NON-NLS-1$ static final String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$ static final String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$ static final 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$ static final String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$ static final String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$ static final String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$ static final String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$ static final String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$ static final String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$ static final String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$ static final String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$ static final String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$public static void error (int code) { error (code, 0);}public static void error (int code, int hresult) { switch (code) { /* Illegal Arguments (non-fatal) */ case ERROR_INVALID_INTERFACE_ADDRESS :{ throw new IllegalArgumentException (ERROR_INVALID_INTERFACE_ADDRESS_MSG); } /* SWT Errors (non-fatal) */ case ERROR_CANNOT_CREATE_FILE : { String msg = ERROR_CANNOT_CREATE_FILE_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } case ERROR_CANNOT_CREATE_OBJECT : { String msg = ERROR_CANNOT_CREATE_OBJECT_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg);//$NON-NLS-1$ } case ERROR_CANNOT_OPEN_FILE : { String msg = ERROR_CANNOT_OPEN_FILE_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } case ERROR_INTERFACE_NOT_FOUND : { String msg = ERROR_INTERFACE_NOT_FOUND_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } case ERROR_INVALID_CLASSID : { String msg = ERROR_INVALID_CLASSID_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } case ERROR_CANNOT_ACCESS_CLASSFACTORY : { String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } case ERROR_CANNOT_CREATE_LICENSED_OBJECT : { String msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } case ERROR_CANNOT_CHANGE_VARIANT_TYPE : { String msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } case ERROR_APPLICATION_NOT_FOUND : { String msg = ERROR_APPLICATION_NOT_FOUND_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } case ERROR_ACTION_NOT_PERFORMED : { String msg = ERROR_ACTION_NOT_PERFORMED_MSG; if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$ throw new SWTException (code, msg); } /* OS Failure/Limit (fatal, may occur only on some platforms) */ case ERROR_OUT_OF_MEMORY : { String msg = ERROR_ACTION_NOT_PERFORMED_MSG; if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$ throw new SWTError (code, msg); } } /* Unknown/Undefined Error */ SWT.error(code);}/* * Finds the OLE program id that is associated with an extension. * The extension may or may not begin with a '.'. On platforms * that do not support OLE, an empty string is returned. * * @param extension the program extension * @return a string that is the OLE program id or an empty string * * @exception SWTError <ul> * <li>ERROR_NULL_ARGUMENT when extension is null</li> * </ul> */public static String findProgramID (String extension) { if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); if (extension.length () == 0) return ""; //$NON-NLS-1$ if (extension.charAt (0) != '.') extension = "." + extension; //$NON-NLS-1$ /* Use the character encoding for the default locale */ TCHAR extensionKey = new TCHAR(0, extension, true); if (result != null) { // look for "<programID>\NotInsertable" TCHAR notInsertableKey = new TCHAR(0, result+"\\NotInsertable", true); //$NON-NLS-1$ if (getKeyExists(notInsertableKey)) return ""; //$NON-NLS-1$ // look for "<programID>\Insertable" TCHAR insertableKey = new TCHAR(0, result+"\\Insertable", true); //$NON-NLS-1$ if (getKeyExists(insertableKey)) return result; // look for "<programID>\protocol\StdFileEditing\server" TCHAR serverKey = new TCHAR(0, result+"\\protocol\\StdFileEditing\\server", true); //$NON-NLS-1$ if (getKeyExists(serverKey)) return result; } return ""; //$NON-NLS-1$}static String getKeyValue (TCHAR key) { int [] phkResult = new int [1]; if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) { return null; } String result = null; int [] lpcbData = new int [1]; if (OS.RegQueryValueEx (phkResult [0], (TCHAR) null, 0, null, null, lpcbData) == 0) { int length = lpcbData [0] / TCHAR.sizeof; if (length == 0) { result = ""; } else { /* Use the character encoding for the default locale */ TCHAR lpData = new TCHAR (0, length); if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) { length = Math.max(0, lpData.length () - 1); result = lpData.toString (0, length); } } } if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]); return result;}private static boolean getKeyExists (TCHAR key) { int [] phkResult = new int [1]; if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) { return false; } if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]); return true;}/** * Returns true if the specified file has an OLE Storage format. * * Note all empty files (regardless of extension) will return false. * * @param file the file to be checked * * @return true if this file has an OLE Storage format */public static boolean isOleFile(File file) { if (file == null || !file.exists() || file.isDirectory()) return false; return (COM.StgIsStorageFile((file.getAbsolutePath()+"\0").toCharArray()) == COM.S_OK);}}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -