java注册表格局代码 java注册表格局代码怎么写

java修改注册表import com.ice.jni.registry.*;
import java.text.SimpleDateFormat;
public class RegeditTool {
static SimpleDateFormat shortDateFormat =new SimpleDateFormat("yyyy-MM-dd");
//把信息存储到注册表HKEY_LOCAL_MACHINE下的某个节点的某一变量中,有则修改,无则创建
public static boolean setValue(String folder, String subKeyNode, String subKeyName, String subKeyValue) {
try{
RegistryKey software = Registry.HKEY_LOCAL_MACHINE
.openSubKey(folder);
RegistryKey subKey = software.createSubKey(subKeyNode, "");
subKey.setValue(new RegStringValue(subKey, subKeyName, subKeyValue));
subKey.closeKey();
return true;
}catch(NoSuchKeyException e) {
e.printStackTrace();
}catch(NoSuchValueException e) {
e.printStackTrace();
}catch(RegistryException e) {
e.printStackTrace();
}
return false;
}
//删除注册表中某节点下的某个变量
【java注册表格局代码 java注册表格局代码怎么写】public static boolean deleteValue(String folder, String subKeyNode,String subKeyName) {
try{
RegistryKey software = Registry.HKEY_LOCAL_MACHINE
.openSubKey(folder);
RegistryKey subKey = software.createSubKey(subKeyNode, "");
subKey.deleteValue(subKeyName);
subKey.closeKey();
return true;
}catch (NoSuchKeyException e) {
System.out.println("NOsuchKey_delete");
}catch (NoSuchValueException e) {
System.out.println("NOsuchValue_delete");
}catch(RegistryException e) {
e.printStackTrace();
}
return false;
}
//删除注册表中某节点下的某节点
public static boolean deleteSubKey(String folder, String subKeyNode) {
try{
RegistryKey software = Registry.HKEY_LOCAL_MACHINE.openSubKey(folder);
software.deleteSubKey(subKeyNode);
software.closeKey();
return true;
}
catch (NoSuchKeyException e) {
e.printStackTrace();
}catch(RegistryException e) {
e.printStackTrace();
}
return false;
}
//打开注册表项并读出相应的变量名的值
public static String getValue(String folder, String subKeyNode,String subKeyName) {
String valuehttps://www.04ip.com/post/= "";
try{
RegistryKey software = Registry.HKEY_LOCAL_MACHINE
.openSubKey(folder);
RegistryKey subKey = software.openSubKey(subKeyNode);
value = https://www.04ip.com/post/subKey.getStringValue(subKeyName);
subKey.closeKey();
}catch(NoSuchKeyException e) {
valuehttps://www.04ip.com/post/= "NoSuchKey";
// e.printStackTrace();
}catch (NoSuchValueException e) {
valuehttps://www.04ip.com/post/= "NoSuchValue";
// e.printStackTrace();
}catch(RegistryException e) {
e.printStackTrace();
}
retur value;
}
//测试
public static void main(String[] args) {
setValue("SOFTWARE", "Microsoft\\Windows\\CurrentVersion\\Run", "test",
"C:\\1.exe");
}
}
用java程序怎么获取电脑注册表某一值 , 路径是HKEY_LOCAL_MACHINE\SOFTWARE\Unigraphics Solutions\NX\8.5import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
String commond = "reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\360Safe\\360Scan\\NetProbe";
try {
Process ps = null;
ps = Runtime.getRuntime().exec(commond);
ps.getOutputStream().close();
InputStreamReader i = new InputStreamReader(ps.getInputStream());
String line;
BufferedReader ir = new BufferedReader(i);
while ((line = ir.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
请用java如何编程实现修改pc互联网IP通过 Java 修改注册表可以达到更改 IP地址的目的 。

推荐阅读