本文整理汇总了Java中com.sun.jna.platform.win32.WinReg.HKEY属性的典型用法代码示例。如果您正苦于以下问题:Java WinReg.HKEY属性的具体用法?Java WinReg.HKEY怎么用?Java WinReg.HKEY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.jna.platform.win32.WinReg
的用法示例。
在下文中一共展示了WinReg.HKEY属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkKeyExists
private void checkKeyExists(
String rootKey,
String keyPath,
String keyName ) {
try {
WinReg.HKEY rootHKey = getHKey(rootKey);
if (!Advapi32Util.registryValueExists(rootHKey, keyPath, keyName)) {
throw new RegistryOperationsException("Registry key does not exist. "
+ getDescription(rootKey, keyPath, keyName));
}
} catch (Win32Exception e) {
throw new RegistryOperationsException("Registry key path does not exist. "
+ getDescription(rootKey, keyPath, keyName), e);
}
}
示例2: getHKey
private WinReg.HKEY getHKey(
String key ) {
if (key.equalsIgnoreCase(HKEY_CLASSES_ROOT)) {
return WinReg.HKEY_CLASSES_ROOT;
} else if (key.equalsIgnoreCase(HKEY_CURRENT_USER)) {
return WinReg.HKEY_CURRENT_USER;
} else if (key.equalsIgnoreCase(HKEY_LOCAL_MACHINE)) {
return WinReg.HKEY_LOCAL_MACHINE;
} else if (key.equalsIgnoreCase(HKEY_USERS)) {
return WinReg.HKEY_USERS;
} else if (key.equalsIgnoreCase(HKEY_CURRENT_CONFIG)) {
return WinReg.HKEY_CURRENT_CONFIG;
} else {
throw new RegistryOperationsException("Unsupported root key '" + key + "'");
}
}
示例3: getOsuInstallationDirectory
/**
* Returns the osu! installation directory.
* @return the directory, or null if not found
*/
private static File getOsuInstallationDirectory() {
if (!System.getProperty("os.name").startsWith("Win"))
return null; // only works on Windows
// registry location
final WinReg.HKEY rootKey = WinReg.HKEY_CLASSES_ROOT;
final String regKey = "osu\\DefaultIcon";
final String regValue = null; // default value
final String regPathPattern = "\"(.+)\\\\[^\\/]+\\.exe\"";
String value;
try {
value = Advapi32Util.registryGetStringValue(rootKey, regKey, regValue);
} catch (Win32Exception e) {
return null; // key/value not found
}
Pattern pattern = Pattern.compile(regPathPattern);
Matcher m = pattern.matcher(value);
if (!m.find())
return null;
File dir = new File(m.group(1));
return (dir.isDirectory()) ? dir : null;
}
示例4: isAddedToContextMenu
public static boolean isAddedToContextMenu() {
if (!Platform.isWindows()) {
return false;
}
final WinReg.HKEY REG_CLASSES_HKEY = WinReg.HKEY_LOCAL_MACHINE;
final String REG_CLASSES_PATH = "Software\\Classes\\";
try {
if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + ".swf")) {
return false;
}
String clsName = Advapi32Util.registryGetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + ".swf", "");
if (clsName == null) {
return false;
}
return Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\ffdec");
} catch (Win32Exception ex) {
return false;
}
}
示例5: loadOsuInstallationDirectory
private File loadOsuInstallationDirectory() {
if (!System.getProperty("os.name").startsWith("Win")) {
return null;
}
final WinReg.HKEY rootKey = WinReg.HKEY_CLASSES_ROOT;
final String regKey = "osu\\DefaultIcon";
final String regValue = null; // default value
final String regPathPattern = "\"(.+)\\\\[^\\/]+\\.exe\"";
String value;
try {
value = Advapi32Util.registryGetStringValue(rootKey, regKey, regValue);
} catch (Win32Exception ignored) {
return null;
}
Pattern pattern = Pattern.compile(regPathPattern);
Matcher m = pattern.matcher(value);
if (!m.find()) {
return null;
}
File dir = new File(m.group(1));
if (dir.isDirectory()) {
return dir;
}
return null;
}
示例6: registryDeleteKey
private static void registryDeleteKey(WinReg.HKEY hKey, String keyName) {
boolean exists = Advapi32Util.registryKeyExists(hKey, keyName);
if (exists) {
Advapi32Util.registryDeleteKey(hKey, keyName);
}
}
示例7: registryDeleteValue
private static void registryDeleteValue(WinReg.HKEY root, String keyPath, String valueName) {
boolean exists = Advapi32Util.registryValueExists(root, keyPath, valueName);
if (exists) {
Advapi32Util.registryDeleteValue(root, keyPath, valueName);
}
}