Source Code Cross Referenced for OLE.java in  » IDE-Eclipse » swt » org » eclipse » swt » ole » win32 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » swt » org.eclipse.swt.ole.win32 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.swt.ole.win32;
011:
012:        import org.eclipse.swt.*;
013:        import java.io.File;
014:        import org.eclipse.swt.internal.ole.win32.COM;
015:        import org.eclipse.swt.internal.win32.OS;
016:        import org.eclipse.swt.internal.win32.TCHAR;
017:
018:        /**
019:         *
020:         * OLE contains all the constants used to create an ActiveX Control or an OLE Document.
021:         *
022:         * <p>Definitions for these constants can be found in MSDN.
023:         *
024:         */
025:        public class OLE extends SWT {
026:
027:            public static final int S_FALSE = 1; // Used for functions that semantically return a Boolean FALSE result to indicate that the function succeeded.
028:            public static final int S_OK = 0; // Function succeeded.
029:            public static final int E_FAIL = -2147467259; // Unspecified failure.
030:            public static final int E_INVALIDARG = -2147024809; // Invalid argument
031:            public static final int E_NOINTERFACE = -2147467262; // QueryInterface did not recognize the requested interface.
032:            public static final int E_NOTIMPL = -2147467263; // Not implemented
033:
034:            public static final String IID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}"; //$NON-NLS-1$
035:            public static final String IID_IDISPATCH = "{00020400-0000-0000-C000-000000000046}"; //$NON-NLS-1$
036:
037:            // Verbs that can be invoked on this client
038:            public static final int OLEIVERB_DISCARDUNDOSTATE = -6; // close the OLE object and discard the undo state
039:            public static final int OLEIVERB_HIDE = -3; // hide the OLE object
040:            public static final int OLEIVERB_INPLACEACTIVATE = -5; // open the OLE for editing in-place
041:            public static final int OLEIVERB_OPEN = -2; // open the OLE object for editing in a separate window
042:            public static final int OLEIVERB_PRIMARY = 0; // opens the OLE object for editing
043:            public static final int OLEIVERB_PROPERTIES = -7; // request the OLE object properties dialog
044:            public static final int OLEIVERB_SHOW = -1; // show the OLE object
045:            public static final int OLEIVERB_UIACTIVATE = -4; // activate the UI for the OLE object
046:
047:            public static final int PROPERTY_CHANGING = 0;
048:            public static final int PROPERTY_CHANGED = 1;
049:
050:            /**
051:             * Error code for OleError - No specific error information available
052:             */
053:            public static final int HRESULT_UNSPECIFIED = 0;
054:            /**
055:             * Error code for OleError - Failed to create file
056:             */
057:            public static final int ERROR_CANNOT_CREATE_FILE = 1000;
058:            /**
059:             * Error code for OleError - Failed to create Ole Client
060:             */
061:            public static final int ERROR_CANNOT_CREATE_OBJECT = 1001;
062:            /**
063:             * Error code for OleError - File does not exist, is not accessible to user or does not have the correct format
064:             */
065:            public static final int ERROR_CANNOT_OPEN_FILE = 1002;
066:            /**
067:             * Error code for OleError - Failed to find requested interface on OLE Object
068:             */
069:            public static final int ERROR_INTERFACE_NOT_FOUND = 1003;
070:            /**
071:             * Error code for OleError - Class ID not found in registry
072:             */
073:            public static final int ERROR_INVALID_CLASSID = 1004;
074:            /**
075:             * Error code for OleError - Failed to get the class factory for the specified classID
076:             */
077:            public static final int ERROR_CANNOT_ACCESS_CLASSFACTORY = 1005;
078:            /**
079:             * Error code for OleError - Failed to create Licensed instance
080:             */
081:            public static final int ERROR_CANNOT_CREATE_LICENSED_OBJECT = 1006;
082:            /**
083:             * Error code for OleError - Out of Memory
084:             */
085:            public static final int ERROR_OUT_OF_MEMORY = 1007;
086:            /**
087:             * Error code for OleError - Failed to change Variant type
088:             */
089:            public static final int ERROR_CANNOT_CHANGE_VARIANT_TYPE = 1010;
090:            /**
091:             * Error code for OleError - Invalid address received for Ole Interface
092:             */
093:            public static final int ERROR_INVALID_INTERFACE_ADDRESS = 1011;
094:            /**
095:             * Error code for OleError - Unable to find Application
096:             */
097:            public static final int ERROR_APPLICATION_NOT_FOUND = 1013;
098:            /**
099:             * Error code for OleError - Action can not be performed
100:             */
101:            public static final int ERROR_ACTION_NOT_PERFORMED = 1014;
102:
103:            public static final int OLECMDF_SUPPORTED = 1;
104:            public static final int OLECMDF_ENABLED = 2;
105:            public static final int OLECMDF_LATCHED = 4;
106:            public static final int OLECMDF_NINCHED = 8;
107:
108:            public static final int OLECMDTEXTF_NONE = 0;
109:            public static final int OLECMDTEXTF_NAME = 1;
110:            public static final int OLECMDTEXTF_STATUS = 2;
111:
112:            public static final int OLECMDEXECOPT_DODEFAULT = 0;
113:            public static final int OLECMDEXECOPT_PROMPTUSER = 1;
114:            public static final int OLECMDEXECOPT_DONTPROMPTUSER = 2;
115:            public static final int OLECMDEXECOPT_SHOWHELP = 3;
116:
117:            public static final int OLECMDID_OPEN = 1;
118:            public static final int OLECMDID_NEW = 2;
119:            public static final int OLECMDID_SAVE = 3;
120:            public static final int OLECMDID_SAVEAS = 4;
121:            public static final int OLECMDID_SAVECOPYAS = 5;
122:            public static final int OLECMDID_PRINT = 6;
123:            public static final int OLECMDID_PRINTPREVIEW = 7;
124:            public static final int OLECMDID_PAGESETUP = 8;
125:            public static final int OLECMDID_SPELL = 9;
126:            public static final int OLECMDID_PROPERTIES = 10;
127:            public static final int OLECMDID_CUT = 11;
128:            public static final int OLECMDID_COPY = 12;
129:            public static final int OLECMDID_PASTE = 13;
130:            public static final int OLECMDID_PASTESPECIAL = 14;
131:            public static final int OLECMDID_UNDO = 15;
132:            public static final int OLECMDID_REDO = 16;
133:            public static final int OLECMDID_SELECTALL = 17;
134:            public static final int OLECMDID_CLEARSELECTION = 18;
135:            public static final int OLECMDID_ZOOM = 19;
136:            public static final int OLECMDID_GETZOOMRANGE = 20;
137:            public static final int OLECMDID_UPDATECOMMANDS = 21;
138:            public static final int OLECMDID_REFRESH = 22;
139:            public static final int OLECMDID_STOP = 23;
140:            public static final int OLECMDID_HIDETOOLBARS = 24;
141:            public static final int OLECMDID_SETPROGRESSMAX = 25;
142:            public static final int OLECMDID_SETPROGRESSPOS = 26;
143:            public static final int OLECMDID_SETPROGRESSTEXT = 27;
144:            public static final int OLECMDID_SETTITLE = 28;
145:            public static final int OLECMDID_SETDOWNLOADSTATE = 29;
146:            public static final int OLECMDID_STOPDOWNLOAD = 30;
147:
148:            /* Ole Property Description flags */
149:            public static int VARFLAG_FREADONLY = 0x1;
150:            public static int VARFLAG_FSOURCE = 0x2;
151:            public static int VARFLAG_FBINDABLE = 0x4;
152:            public static int VARFLAG_FREQUESTEDIT = 0x8;
153:            public static int VARFLAG_FDISPLAYBIND = 0x10;
154:            public static int VARFLAG_FDEFAULTBIND = 0x20;
155:            public static int VARFLAG_FHIDDEN = 0x40;
156:            public static int VARFLAG_FRESTRICTED = 0x80;
157:            public static int VARFLAG_FDEFAULTCOLLELEM = 0x100;
158:            public static int VARFLAG_FUIDEFAULT = 0x200;
159:            public static int VARFLAG_FNONBROWSABLE = 0x400;
160:            public static int VARFLAG_FREPLACEABLE = 0x800;
161:            public static int VARFLAG_FIMMEDIATEBIND = 0x1000;
162:
163:            /* Ole Property Description kind */
164:            public static int VAR_PERINSTANCE = 0;
165:            public static int VAR_STATIC = 1;
166:            public static int VAR_CONST = 2;
167:            public static int VAR_DISPATCH = 3;
168:
169:            /* Ole Parameter Description flags */
170:            public static short IDLFLAG_NONE = 0;
171:            public static short IDLFLAG_FIN = 1;
172:            public static short IDLFLAG_FOUT = 2;
173:            public static short IDLFLAG_FLCID = 4;
174:            public static short IDLFLAG_FRETVAL = 8;
175:
176:            /* Ole Description types */
177:            public static final short VT_BOOL = 11; // Boolean; True=-1, False=0.
178:            public static final short VT_BSTR = 8; // Binary String.
179:            public static final short VT_BYREF = 16384; // By reference - must be combined with one of the other VT values
180:            public static final short VT_CY = 6; // Currency.
181:            public static final short VT_DATE = 7; // Date.
182:            public static final short VT_DISPATCH = 9; // IDispatch
183:            public static final short VT_EMPTY = 0; // Not specified.
184:            public static final short VT_ERROR = 10; // Scodes.
185:            public static final short VT_I2 = 2; // 2-byte signed int.
186:            public static final short VT_I4 = 3; // 4-byte signed int.
187:            public static final short VT_NULL = 1; // Null.
188:            public static final short VT_R4 = 4; // 4-byte real.
189:            public static final short VT_R8 = 5; // 8-byte real.
190:            public static final short VT_UI1 = 17; // Unsigned char.
191:            public static final short VT_UI4 = 19; // Unsigned int.
192:            public static final short VT_UNKNOWN = 13; // IUnknown FAR*.
193:            public static final short VT_VARIANT = 12; // VARIANT FAR*.
194:            public static final short VT_PTR = 26;
195:            public static final short VT_USERDEFINED = 29;
196:            public static final short VT_HRESULT = 25;
197:            public static final short VT_DECIMAL = 14;
198:            public static final short VT_I1 = 16;
199:            public static final short VT_UI2 = 18;
200:            public static final short VT_I8 = 20;
201:            public static final short VT_UI8 = 21;
202:            public static final short VT_INT = 22;
203:            public static final short VT_UINT = 23;
204:            public static final short VT_VOID = 24;
205:            public static final short VT_SAFEARRAY = 27;
206:            public static final short VT_CARRAY = 28;
207:            public static final short VT_LPSTR = 30;
208:            public static final short VT_LPWSTR = 31;
209:            public static final short VT_RECORD = 36;
210:            public static final short VT_FILETIME = 64;
211:            public static final short VT_BLOB = 65;
212:            public static final short VT_STREAM = 66;
213:            public static final short VT_STORAGE = 67;
214:            public static final short VT_STREAMED_OBJECT = 68;
215:            public static final short VT_STORED_OBJECT = 69;
216:            public static final short VT_BLOB_OBJECT = 70;
217:            public static final short VT_CF = 71;
218:            public static final short VT_CLSID = 72;
219:            public static final short VT_VERSIONED_STREAM = 73;
220:            public static final short VT_BSTR_BLOB = 0xfff;
221:            public static final short VT_VECTOR = 0x1000;
222:            public static final short VT_ARRAY = 0x2000;
223:
224:            /* Ole Function Description Invoke Kind values */
225:            public static final int INVOKE_FUNC = 1;
226:            public static final int INVOKE_PROPERTYGET = 2;
227:            public static final int INVOKE_PROPERTYPUT = 4;
228:            public static final int INVOKE_PROPERTYPUTREF = 8;
229:
230:            /* Ole Function Description function kind */
231:            public static final int FUNC_VIRTUAL = 0;
232:            public static final int FUNC_PUREVIRTUAL = 1;
233:            public static final int FUNC_NONVIRTUAL = 2;
234:            public static final int FUNC_STATIC = 3;
235:            public static final int FUNC_DISPATCH = 4;
236:
237:            /* Ole Function Description function flags */
238:            public static final short FUNCFLAG_FRESTRICTED = 1;
239:            public static final short FUNCFLAG_FSOURCE = 0x2;
240:            public static final short FUNCFLAG_FBINDABLE = 0x4;
241:            public static final short FUNCFLAG_FREQUESTEDIT = 0x8;
242:            public static final short FUNCFLAG_FDISPLAYBIND = 0x10;
243:            public static final short FUNCFLAG_FDEFAULTBIND = 0x20;
244:            public static final short FUNCFLAG_FHIDDEN = 0x40;
245:            public static final short FUNCFLAG_FUSESGETLASTERROR = 0x80;
246:            public static final short FUNCFLAG_FDEFAULTCOLLELEM = 0x100;
247:            public static final short FUNCFLAG_FUIDEFAULT = 0x200;
248:            public static final short FUNCFLAG_FNONBROWSABLE = 0x400;
249:            public static final short FUNCFLAG_FREPLACEABLE = 0x800;
250:            public static final short FUNCFLAG_FIMMEDIATEBIND = 0x1000;
251:
252:            /* Ole Function Description calling convention */
253:            public static final int CC_FASTCALL = 0;
254:            public static final int CC_CDECL = 1;
255:            public static final int CC_MSCPASCAL = 2;
256:            public static final int CC_PASCAL = 2;
257:            public static final int CC_MACPASCAL = 3;
258:            public static final int CC_STDCALL = 4;
259:            public static final int CC_FPFASTCALL = 5;
260:            public static final int CC_SYSCALL = 6;
261:            public static final int CC_MPWCDECL = 7;
262:            public static final int CC_MPWPASCAL = 8;
263:            public static final int CC_MAX = 9;
264:
265:            static final String ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported.";//$NON-NLS-1$
266:            static final String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$
267:            static final String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$
268:            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$
269:            static final String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$
270:            static final String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$
271:            static final String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$
272:            static final String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$
273:            static final String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$
274:            static final String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$
275:            static final String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$
276:            static final String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$
277:            static final String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$
278:
279:            public static void error(int code) {
280:                error(code, 0);
281:            }
282:
283:            public static void error(int code, int hresult) {
284:
285:                switch (code) {
286:                /* Illegal Arguments (non-fatal) */
287:                case ERROR_INVALID_INTERFACE_ADDRESS: {
288:                    throw new IllegalArgumentException(
289:                            ERROR_INVALID_INTERFACE_ADDRESS_MSG);
290:                }
291:
292:                    /* SWT Errors (non-fatal) */
293:                case ERROR_CANNOT_CREATE_FILE: {
294:                    String msg = ERROR_CANNOT_CREATE_FILE_MSG;
295:                    if (hresult != 0)
296:                        msg += " result = " + hresult;//$NON-NLS-1$
297:                    throw new SWTException(code, msg);
298:                }
299:                case ERROR_CANNOT_CREATE_OBJECT: {
300:                    String msg = ERROR_CANNOT_CREATE_OBJECT_MSG;
301:                    if (hresult != 0)
302:                        msg += " result = " + hresult;//$NON-NLS-1$
303:                    throw new SWTException(code, msg);//$NON-NLS-1$
304:                }
305:                case ERROR_CANNOT_OPEN_FILE: {
306:                    String msg = ERROR_CANNOT_OPEN_FILE_MSG;
307:                    if (hresult != 0)
308:                        msg += " result = " + hresult;//$NON-NLS-1$
309:                    throw new SWTException(code, msg);
310:                }
311:                case ERROR_INTERFACE_NOT_FOUND: {
312:                    String msg = ERROR_INTERFACE_NOT_FOUND_MSG;
313:                    if (hresult != 0)
314:                        msg += " result = " + hresult;//$NON-NLS-1$
315:                    throw new SWTException(code, msg);
316:                }
317:                case ERROR_INVALID_CLASSID: {
318:                    String msg = ERROR_INVALID_CLASSID_MSG;
319:                    if (hresult != 0)
320:                        msg += " result = " + hresult;//$NON-NLS-1$
321:                    throw new SWTException(code, msg);
322:                }
323:                case ERROR_CANNOT_ACCESS_CLASSFACTORY: {
324:                    String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG;
325:                    if (hresult != 0)
326:                        msg += " result = " + hresult;//$NON-NLS-1$
327:                    throw new SWTException(code, msg);
328:                }
329:                case ERROR_CANNOT_CREATE_LICENSED_OBJECT: {
330:                    String msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG;
331:                    if (hresult != 0)
332:                        msg += " result = " + hresult;//$NON-NLS-1$
333:                    throw new SWTException(code, msg);
334:                }
335:                case ERROR_CANNOT_CHANGE_VARIANT_TYPE: {
336:                    String msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG;
337:                    if (hresult != 0)
338:                        msg += " result = " + hresult;//$NON-NLS-1$
339:                    throw new SWTException(code, msg);
340:                }
341:                case ERROR_APPLICATION_NOT_FOUND: {
342:                    String msg = ERROR_APPLICATION_NOT_FOUND_MSG;
343:                    if (hresult != 0)
344:                        msg += " result = " + hresult;//$NON-NLS-1$
345:                    throw new SWTException(code, msg);
346:                }
347:                case ERROR_ACTION_NOT_PERFORMED: {
348:                    String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
349:                    if (hresult != 0)
350:                        msg += " result = " + hresult;//$NON-NLS-1$
351:                    throw new SWTException(code, msg);
352:                }
353:
354:                    /* OS Failure/Limit (fatal, may occur only on some platforms) */
355:                case ERROR_OUT_OF_MEMORY: {
356:                    String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
357:                    if (hresult != 0)
358:                        msg += " result = " + hresult; //$NON-NLS-1$
359:                    throw new SWTError(code, msg);
360:                }
361:                }
362:
363:                /* Unknown/Undefined Error */
364:                SWT.error(code);
365:            }
366:
367:            /*
368:             * Finds the OLE program id that is associated with an extension.
369:             * The extension may or may not begin with a '.'.  On platforms
370:             * that do not support OLE, an empty string is returned.
371:             *
372:             * @param extension the program extension
373:             * @return a string that is the OLE program id or an empty string
374:             *
375:             * @exception IllegalArgumentException <ul>
376:             *		<li>ERROR_NULL_ARGUMENT when extension is null</li>
377:             *	</ul>
378:             */
379:            public static String findProgramID(String extension) {
380:                if (extension == null)
381:                    SWT.error(SWT.ERROR_NULL_ARGUMENT);
382:                if (extension.length() == 0)
383:                    return ""; //$NON-NLS-1$
384:
385:                if (extension.charAt(0) != '.')
386:                    extension = "." + extension; //$NON-NLS-1$
387:
388:                /* Use the character encoding for the default locale */
389:                TCHAR extensionKey = new TCHAR(0, extension, true);
390:                String result = getKeyValue(extensionKey);
391:                if (result != null) {
392:                    // look for "<programID>\NotInsertable"
393:                    TCHAR notInsertableKey = new TCHAR(0, result
394:                            + "\\NotInsertable", true); //$NON-NLS-1$
395:                    if (getKeyExists(notInsertableKey))
396:                        return ""; //$NON-NLS-1$
397:                    // look for "<programID>\Insertable"
398:                    TCHAR insertableKey = new TCHAR(0,
399:                            result + "\\Insertable", true); //$NON-NLS-1$
400:                    if (getKeyExists(insertableKey))
401:                        return result;
402:                    // look for "<programID>\protocol\StdFileEditing\server"
403:                    TCHAR serverKey = new TCHAR(0, result
404:                            + "\\protocol\\StdFileEditing\\server", true); //$NON-NLS-1$
405:                    if (getKeyExists(serverKey))
406:                        return result;
407:                }
408:
409:                return ""; //$NON-NLS-1$
410:            }
411:
412:            static String getKeyValue(TCHAR key) {
413:                int /*long*/[] phkResult = new int /*long*/[1];
414:                if (OS.RegOpenKeyEx(OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ,
415:                        phkResult) != 0) {
416:                    return null;
417:                }
418:                String result = null;
419:                int[] lpcbData = new int[1];
420:                if (OS.RegQueryValueEx(phkResult[0], (TCHAR) null, 0, null,
421:                        (TCHAR) null, lpcbData) == 0) {
422:                    int length = lpcbData[0] / TCHAR.sizeof;
423:                    if (length == 0) {
424:                        result = "";
425:                    } else {
426:                        /* Use the character encoding for the default locale */
427:                        TCHAR lpData = new TCHAR(0, length);
428:                        if (OS.RegQueryValueEx(phkResult[0], null, 0, null,
429:                                lpData, lpcbData) == 0) {
430:                            length = Math.max(0, lpData.length() - 1);
431:                            result = lpData.toString(0, length);
432:                        }
433:                    }
434:                }
435:                if (phkResult[0] != 0)
436:                    OS.RegCloseKey(phkResult[0]);
437:                return result;
438:            }
439:
440:            private static boolean getKeyExists(TCHAR key) {
441:                int /*long*/[] phkResult = new int /*long*/[1];
442:                if (OS.RegOpenKeyEx(OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ,
443:                        phkResult) != 0) {
444:                    return false;
445:                }
446:                if (phkResult[0] != 0)
447:                    OS.RegCloseKey(phkResult[0]);
448:                return true;
449:            }
450:
451:            /**
452:             * Returns true if the specified file has an OLE Storage format.
453:             *
454:             * Note all empty files (regardless of extension) will return false.
455:             *
456:             * @param file the file to be checked
457:             *
458:             * @return true if this file has an OLE Storage format
459:             */
460:            public static boolean isOleFile(File file) {
461:                if (file == null || !file.exists() || file.isDirectory())
462:                    return false;
463:
464:                return (COM.StgIsStorageFile((file.getAbsolutePath() + "\0")
465:                        .toCharArray()) == COM.S_OK);
466:            }
467:
468:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.