当前位置: 首页>>代码示例>>Java>>正文


Java WinReg.HKEY属性代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:16,代码来源:LocalRegistryOperations.java

示例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 + "'");
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:17,代码来源:LocalRegistryOperations.java

示例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;
}
 
开发者ID:itdelatrisu,项目名称:opsu,代码行数:27,代码来源:Options.java

示例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;
    }
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:19,代码来源:ContextMenuTools.java

示例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;
}
 
开发者ID:yugecin,项目名称:opsu-dance,代码行数:27,代码来源:Configuration.java

示例6: registryDeleteKey

private static void registryDeleteKey(WinReg.HKEY hKey, String keyName) {
    boolean exists = Advapi32Util.registryKeyExists(hKey, keyName);
    if (exists) {
        Advapi32Util.registryDeleteKey(hKey, keyName);
    }
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:6,代码来源:ContextMenuTools.java

示例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);
    }
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:6,代码来源:ContextMenuTools.java


注:本文中的com.sun.jna.platform.win32.WinReg.HKEY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。