Source Code Cross Referenced for JNIWindowsShortcut.java in  » Installer » VAInstall » com » memoire » vainstall » 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 » Installer » VAInstall » com.memoire.vainstall 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * @creation 28/02/05
003:         *
004:         */package com.memoire.vainstall;
005:
006:        import java.io.File;
007:        import java.io.IOException;
008:
009:        /**
010:         * A means of creating Windows shortcuts using the JNI interface.
011:         * @author Dick Repasky
012:         *
013:         */
014:
015:        public class JNIWindowsShortcut {
016:            /** Value for location. 
017:            	If you use this value,
018:            	the value of linkname
019:            	should include the
020:            	full name of the
021:            	directory that will
022:            	contain the new link. */
023:            public static final int CUSTOM_LOCATION = 0;
024:            /** Value for location. */
025:            public static final int ON_DESKTOP = 1;
026:            /** Value for location. */
027:            public static final int ON_START_MENU = 2;
028:
029:            /** Value for forwhom. */
030:            public static final int USER_ONLY = 0;
031:            /** Value for forwhom. */
032:            public static final int EVERYBODY = 1;
033:
034:            /** Value for openas. */
035:            public static final int SHOW_NORMAL = 0;
036:            /** Value for openas. */
037:            public static final int SHOW_MAX = 1;
038:            /** Value for openas. */
039:            public static final int SHOW_MIN = 2;
040:
041:            public static boolean isDllLoaded_;
042:
043:            public static void loadLib() {
044:                if (!isDllLoaded_) {
045:                    isDllLoaded_ = true;
046:                    System.load(LIB_NAME);
047:                }
048:            }
049:
050:            /** Name of dll. */
051:            public static String LIB_NAME = "JNIWinShortcut";
052:            private static final String DEFAULT_LINK = "LaunchIt";
053:
054:            /** Create a Windows Shortcut using the information provided. 
055:            	@parm target name - binary to be executed. Required.
056:            			Must be fully qualified path to work.
057:            	@parm workingdir - name of working directory for running 
058:            		binary. Required.
059:            			Must be fully qualified path to work.
060:            	@parm args	- arguments to be passed to the binary. 
061:            			Optional.
062:            	@parm linkname	- name of the link file.  Omit .LNK suffix!
063:            			Include leading directory names only if
064:            			location is CUSTOM_LOCATION.
065:            	@parm location - one of CUSTOM_LOCATION, ON_DESKTOP, 
066:            			ON_STARTMENU.
067:            	@parm forwhom  - one of USER_ONLY or EVERYBODY. Ignored if
068:            			location is CUSTOM_LOCATION.
069:            	@parm iconfile - name of icon file. Must be fully qualified
070:            			path to work.
071:            	@parm iconoffset - offest of icon within iconfile.
072:            	@parm description - speak freely here. But, be brief. I don't
073:            			know what the limit is.
074:             */
075:            public static final String createShortcut(String targetname,
076:                    String workingdir, String args, int openas,
077:                    String linkname, int location, int forwhom,
078:                    String iconfile, int iconoffset, String description)
079:                    throws IOException {
080:                loadLib();
081:                if (targetname == null)
082:                    targetname = "";
083:                if (workingdir == null)
084:                    workingdir = "";
085:                if (args == null)
086:                    args = "";
087:                if (linkname == null || linkname.length() == 0)
088:                    linkname = DEFAULT_LINK;
089:                if (iconfile == null)
090:                    iconfile = "";
091:                if (description == null)
092:                    description = "";
093:                String f = createShortcutJNI(targetname, workingdir, args,
094:                        openas, linkname, location, forwhom, iconfile,
095:                        iconoffset, description);
096:                File shortcutFile = new File(f);
097:                if (!shortcutFile.exists()) {
098:                    if (VAGlobals.DEBUG)
099:                        VAGlobals.printDebug("shortcut not found "
100:                                + shortcutFile.getName());
101:                    String name = shortcutFile.getName();
102:                    int idxDot = name.lastIndexOf('.');
103:                    if (idxDot > 0) {
104:                        name = name.substring(0, idxDot);
105:                        File test = new File(shortcutFile.getParentFile(), name
106:                                + ".pif");
107:                        System.err.println("file tested " + test);
108:                        if (test.exists()) {
109:                            if (VAGlobals.DEBUG)
110:                                VAGlobals.printDebug("shortcut guessed "
111:                                        + test.getName());
112:
113:                            f = test.getAbsolutePath();
114:                        }
115:                    }
116:                }
117:                return f;
118:            }
119:
120:            /**
121:             * Return the name of the directory that would contain
122:             * a link of the type give.
123:             * @parm location should be one of ON_DESKTOP or ON_START_MENU.
124:             * @parm forwhom should be one of EVERYBODY or USER_ONLY.
125:             *
126:             */
127:
128:            public static final String getShortcutDir(int location, int forwhom) {
129:                loadLib();
130:                return getLinkDir(location, forwhom);
131:            }
132:
133:            /**
134:             * Return the name of the shortcut that would be created if
135:             * the following arguments were used.  Arguments are as
136:             * for createShortcut. 
137:             * @exception java.io.IOException if full path name is
138:             * longer than maximum allowed.
139:             */
140:
141:            public static final String getShortcutName(String linkname,
142:                    int location, int forwhom) throws IOException {
143:                loadLib();
144:                if (linkname == null || linkname.length() == 0)
145:                    linkname = DEFAULT_LINK;
146:                return getLinkName(linkname, location, forwhom);
147:            }
148:
149:            /**
150:             * Return maximum allowable Win32 path length (i.e.,
151:             * value of the constant MAX_PATH).
152:             *
153:             */
154:
155:            public static final int getMaxPathlength() {
156:                loadLib();
157:                return getMAX_PATH();
158:            }
159:
160:            /** Create a shortcut. */
161:            private static final native String createShortcutJNI(
162:                    String targetname, String workingdir, String args,
163:                    int openas, String linkname, int location, int forwhom,
164:                    String iconfile, int iconoffset, String descriptions)
165:                    throws IOException;
166:
167:            /**
168:             * Get the name of the directory for links of the type
169:             * given.
170:             *
171:             */
172:            private static final native String getLinkDir(int location,
173:                    int forwhom);
174:
175:            /**
176:             * Get the full file name of a shortcut that would
177:             * be created using the arguments.
178:             * @exception java.io.IOException if full path name is
179:             * longer than maximum allowed.
180:             */
181:
182:            private static final native String getLinkName(String linkname,
183:                    int location, int forwhom) throws IOException;
184:
185:            /**
186:             * Return value of Win32 MAX_PATH.
187:             *
188:             */
189:
190:            private static final native int getMAX_PATH();
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.