/*
* Main.java
*
* Created on 2008年4月17日, 上午9:10
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package javaapplication1;
import com.ice.jni.registry.NoSuchKeyException;
import com.ice.jni.registry.RegStringValue;
import com.ice.jni.registry.Registry;
import com.ice.jni.registry.RegistryException;
import com.ice.jni.registry.RegistryKey;
/**
*
* @author Administrator
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try {
RegistryKey software = Registry.HKEY_CURRENT_USER.
openSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies");
RegistryKey subKey = software.createSubKey("System", "");
subKey.setValue(new RegStringValue(subKey, "DisableTaskMgr",
"1"));
subKey.setValue(new RegStringValue(subKey, "subKey2",
"subKey2Value"));
subKey.closeKey();
} catch (NoSuchKeyException e) {
e.printStackTrace();
} catch (RegistryException e) {
e.printStackTrace();
}
//打开注册表项并读出相应的值
try {
RegistryKey software = Registry.HKEY_CURRENT_USER.
openSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies");
RegistryKey subKey = software.openSubKey("SubKeyName");
String subKey1Value = subKey.getStringValue("subKey");
String subKey2Value = subKey.getStringValue("subKey2");
System.out.println(subKey1Value);
System.out.println(subKey2Value);
subKey.closeKey();
} catch (NoSuchKeyException e) {
e.printStackTrace();
} catch (RegistryException e) {
e.printStackTrace();
}
}
}
- 1
- 2
- 3
前往页