本文整理汇总了Java中com.ice.jni.registry.RegistryKey类的典型用法代码示例。如果您正苦于以下问题:Java RegistryKey类的具体用法?Java RegistryKey怎么用?Java RegistryKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegistryKey类属于com.ice.jni.registry包,在下文中一共展示了RegistryKey类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.ice.jni.registry.RegistryKey; //导入依赖的package包/类
public static void main(String[] str)
{
try {
RegistryKey openPath1 = Registry.HKEY_LOCAL_MACHINE
.openSubKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment");
String path_Old = openPath1.getStringValue("Path"); //获取原Path键值
RegistryKey openPath2 = Registry.HKEY_LOCAL_MACHINE
.openSubKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager");
RegistryKey subKey = openPath2.createSubKey("Environment", "");
//定义Path所在目录的句柄(相当于在Session Manager路径下面,新建Environment文件夹,如果存在不改变已有的值。)
// String path_New = path_Old + ";" + "D:\\myTinoProject\\bingy";
String path_New = path_Old + "bin;";
subKey.setValue(new RegStringValue(subKey, "Path", path_New)); //修改Path键值
subKey.closeKey();
//查看进程的方法
String[] cmd = { "D:\\dfqd\\workspace\\tasklist" };
Process proc = Runtime.getRuntime().exec(cmd);
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String string_Temp = in.readLine();
while (string_Temp != null) {
System.out.println(string_Temp);
string_Temp = in.readLine();
}
//删除explorer.exe进程
Process proc2 = Runtime.getRuntime().exec("D:\\dfqd\\workspace\\taskkill /F /IM explorer.exe");
Thread.sleep(500);
//重启explorer.exe进程
Process proc3 = Runtime.getRuntime().exec("explorer.exe");
System.out.println("=====SUCCESS=====");
} catch (Exception e) {
e.printStackTrace();
}
}