Source Code Cross Referenced for Registry.java in  » J2EE » Sofia » com » salmonllc » 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 » J2EE » Sofia » com.salmonllc.win32 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        // 
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        // 
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        // 
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:        package com.salmonllc.win32;
021:
022:        /**
023:         * Licensed Material - Property of Salmon LLC
024:         * (C) Copyright Salmon LLC. 1999 - All Rights Reserved
025:         * For more information go to www.salmonllc.com
026:         * *
027:         * *************************************************************************
028:         * DISCLAIMER:
029:         * The following code has been created by Salmon LLC. The code is provided
030:         * 'AS IS' , without warranty of any kind unless covered in another agreement
031:         * between your corporation and Salmon LLC.  Salmon LLC shall not be liable
032:         * for any damages arising out of your use of this, even if they have been
033:         * advised of the possibility of such damages.
034:         * *************************************************************************
035:         * *
036:         * This class is used to set a key in the registry. Use the setRegistryEntry method. This class requires REGUPDATE.dll
037:         * To be distributed with it.
038:         * Creation date: (4/16/02 11:43:10 AM)
039:         * @author: Fred Cahill
040:         */
041:        public class Registry {
042:            public final static int HKEY_CLASSES_ROOT = 1;
043:            public final static int HKEY_CURRENT_USER = 2;
044:            public final static int HKEY_LOCAL_MACHINE = 3;
045:            public final static int HKEY_USERS = 4;
046:            private static boolean _isLoaded = false;
047:
048:            private int _type;
049:            private String _key;
050:
051:            static {
052:                loadJNILibrary("REGUPDATE");
053:            }
054:
055:            public Registry(int iType, String sKey) {
056:                _type = iType;
057:                _key = sKey;
058:            }
059:
060:            /**
061:             * Use this method to get a registry value.
062:             * @param iType int This is a constant representing the key type. HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS
063:             * @param sKey java.lang.String This is a string representing the key. e.g. "Software\\Macromedia\\Dreamweaver\\Sites\\-Site0"
064:             * @param sAttribute java.lang.String This is the attribute in that key to be gotten.
065:             * @return The value of the attribute.
066:             */
067:            private static native int getDWordRegistryEntry(int iType,
068:                    String sKey, String sAttribute);
069:
070:            /**
071:             * Use this method to get a registry value.
072:             * @param iType int This is a constant representing the key type. HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS
073:             * @param sKey java.lang.String This is a string representing the key. e.g. "Software\\Macromedia\\Dreamweaver\\Sites\\-Site0"
074:             * @param sAttribute java.lang.String This is the attribute in that key to be gotten.
075:             * @return The value of the attribute.
076:             */
077:            private static native String getRegistryEntry(int iType,
078:                    String sKey, String sAttribute);
079:
080:            /**
081:             * This method specifies the JNI Secure ID dll to use.
082:             * @param sLibrary The name of the dll to be loaded.
083:             */
084:            public static synchronized void loadJNILibrary(String sLibrary) {
085:                try {
086:                    System.err.println("Start to load the library");
087:                    System.loadLibrary(sLibrary);
088:                    System.err.println("Library loaded");
089:                    _isLoaded = true;
090:                } catch (Error err) {
091:                    System.out.println(err);
092:                }
093:            }
094:
095:            /**
096:             * Insert the method's description here.
097:             * Creation date: (4/16/02 12:00:24 PM)
098:             * @param args java.lang.String[]
099:             */
100:            public static void main(String[] args) {
101:                setRegistryEntry(HKEY_CURRENT_USER, "Software\\Test",
102:                        "TestKey", "TestValue");
103:                System.out.println(getDWordRegistryEntry(HKEY_CURRENT_USER,
104:                        "Software\\Macromedia\\Dreamweaver 4\\Sites\\-Summary",
105:                        "Number of Sites"));
106:            }
107:
108:            /**
109:             * Use this method to set a registry value.
110:             * @param iType int This is a constant representing the key type. HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS
111:             * @param sKey java.lang.String This is a string representing the key. e.g. "Software\\Macromedia\\Dreamweaver\\Sites\\-Site0"
112:             * @param sAttribute java.lang.String This is the attribute in that key to be set.
113:             * @param iValue int This is the value to set the attribute to.
114:             */
115:            private static native void setDWordRegistryEntry(int iType,
116:                    String sKey, String sAttribute, int iValue);
117:
118:            /**
119:             * Use this method to set a registry value.
120:             * @param iType int This is a constant representing the key type. HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS
121:             * @param sKey java.lang.String This is a string representing the key. e.g. "Software\\Macromedia\\Dreamweaver\\Sites\\-Site0"
122:             * @param sAttribute java.lang.String This is the attribute in that key to be set.
123:             * @param sValue java.lang.String This is the value to set the attribute to.
124:             */
125:            private static native void setRegistryEntry(int iType, String sKey,
126:                    String sAttribute, String sValue);
127:
128:            /**
129:             * Use this method to get a registry value.
130:             * @param sAttribute java.lang.String This is the attribute in the key to be gotten.
131:             * @return The value of the attribute.
132:             */
133:            public String getStringAttribute(String sAttribute)
134:                    throws RegistryException {
135:                if (!_isLoaded)
136:                    throw new RegistryException(
137:                            "REGUPDATE.DLL has not been loaded.");
138:                return getRegistryEntry(_type, _key, sAttribute);
139:            }
140:
141:            /**
142:             * Use this method to get a registry value.
143:             * @param sAttribute java.lang.String This is the attribute in the key to be gotten.
144:             * @return The value of the attribute.
145:             */
146:            public int getIntAttribute(String sAttribute)
147:                    throws RegistryException {
148:                if (!_isLoaded)
149:                    throw new RegistryException(
150:                            "REGUPDATE.DLL has not been loaded.");
151:                return getDWordRegistryEntry(_type, _key, sAttribute);
152:            }
153:
154:            /**
155:             * Use this method to set a registry value.
156:             * @param sAttribute java.lang.String This is the attribute in the key to be set.
157:             * @param iValue int This is the value to set the attribute to.
158:             */
159:
160:            public void setIntAttribute(String sAttribute, int iValue)
161:                    throws RegistryException {
162:                if (!_isLoaded)
163:                    throw new RegistryException(
164:                            "REGUPDATE.DLL has not been loaded.");
165:                setDWordRegistryEntry(_type, _key, sAttribute, iValue);
166:            }
167:
168:            /**
169:             * Use this method to set a registry value.
170:             * @param sAttribute java.lang.String This is the attribute in the key to be set.
171:             * @param sValue java.lang.String This is the value to set the attribute to.
172:             */
173:
174:            public void setStringAttribute(String sAttribute, String sValue)
175:                    throws RegistryException {
176:                if (!_isLoaded)
177:                    throw new RegistryException(
178:                            "REGUPDATE.DLL has not been loaded.");
179:                setRegistryEntry(_type, _key, sAttribute, sValue);
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.