[英]Detect data type of value in Windows Registry Key with Java
Is it possible to detect the type of a value stored in a Windows registry key using java?是否可以使用 java 检测存储在 Windows 注册表项中的值的类型?
I tried instanceof but that falls short.我试过 instanceof ,但还是不够。
I need to be able to detect if a key value is of any of these types: Binary, DWord, SZ, None, Link, QWord, Multi SZ, Expand SZ, Resource List, Full Resource Descriptor, Resource Requirements List我需要能够检测键值是否属于以下任何类型:二进制、双字、SZ、无、链接、QWord、多 SZ、扩展 SZ、资源列表、完整资源描述符、资源需求列表
Thanks谢谢
Process processIn = Runtime.getRuntime().exec("reg query " + '"'+ regKey + "\" /v " + regSubKey);
StreamReader reader = new StreamReader(processIn.getInputStream());
reader.start();
reader.join();
String read = reader.getResult();
String[] parsed = reader.getResult().split("\\s+");
if (parsed.length > 1) {
read = parsed[parsed.length-2];
System.out.println("type = " + read)
}
Define regKey and regSubKey and this snippet works.定义 regKey 和 regSubKey 并且此代码段有效。 There may be a way to do this cleaner but it works for what I need.可能有一种方法可以做到这一点,但它适用于我所需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.