java 获取注册表键值
来源:互联网 发布:知乎精华化妆品 编辑:程序博客网 时间:2024/04/28 11:40
/**
*
* @param location path in the registry
* @param key registry key
* @return registry value or null if not found
*/
public static final String readRegistry(String location, String key)
{
try
{
// Run reg query, then read output with StreamReader (internal class)
Process process = Runtime.getRuntime().exec("reg query " +
'"'+ location + "\" /v " + key);
InputStream is = process.getInputStream();
StringBuilder sw = new StringBuilder();
try
{
int c;
while ((c = is.read()) != -1)
sw.append((char)c);
}
catch (IOException e)
{
}
String output = sw.toString();
// Output has the following format:
// \n<Version information>\n\n<key> <registry type> <value>\r\n\r\n
int i = output.indexOf("REG_SZ");
if (i == -1)
{
return null;
}
sw = new StringBuilder();
i += 6; // skip REG_SZ
// skip spaces or tabs
for (;;)
{
if (i > output.length())
break;
char c = output.charAt(i);
if (c != ' ' && c != '\t')
break;
++i;
}
// take everything until end of line
for (;;)
{
if (i > output.length())
break;
char c = output.charAt(i);
if (c == '\r' || c == '\n')
break;
sw.append(c);
++i;
}
return sw.toString();
}
catch (Exception e)
{
return null;
}
- java 获取注册表键值
- DOS获取注册表键值
- 利用InstallShield获取注册表键值
- 批处理(DOS)获取注册表键值
- 递归删除注册表与获取注册表的一个键值
- 注册表键值
- 注册表键值
- 注册表处理之(根据注册表路径获取主键值和子键值)
- 注册表常用键值意义
- 读取注册表键值
- 创建注册表键值
- 注册表常用键值意义
- Explorer注册表键值归纳
- VC++删除注册表键值
- 注册表键值作用
- 注册表键值简介
- Explorer注册表键值归纳
- 注册表枚举键值
- Java中多态性的实现
- setEnabled
- Bind Function to Bootstrap Modal Event 模态对话框事件绑定函数
- jquery的$.when方法的运用
- hdu 1272 小希的迷宫(判断成环)
- java 获取注册表键值
- 大量信息渠道和快速提高的途径 - 快速驾驭Unity
- 前端必读:浏览器内部工作原理
- 全局空间自相关算法:Join Count
- TS流PCR简介
- Android中关于Cursor类的用法
- properties文件第一行请空出来
- 前端和后端分工的三种模式
- 10014---JavaWeb基础--请求重定向与请求转发