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


Java WinReg类代码示例

本文整理汇总了Java中com.sun.jna.platform.win32.WinReg的典型用法代码示例。如果您正苦于以下问题:Java WinReg类的具体用法?Java WinReg怎么用?Java WinReg使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WinReg类属于com.sun.jna.platform.win32包,在下文中一共展示了WinReg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAvailableBrowsers

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
public static String[] getAvailableBrowsers() throws DebuggableException {
    try {
        String[] keys = Advapi32Util.registryGetKeys(WinReg.HKEY_LOCAL_MACHINE, WIN_REG_CLIENTS_PATH);

        List<String> filteredList = new ArrayList<String>(50);
        for (int i = 0; i < keys.length; i++) {
            if (!keys[i].equals(WIN_REG_INTERNET_CLIENT_KEY)) {
                filteredList.add(keys[i]);
            }
        }

        String[] out = new String[filteredList.size()];
        for (int i = 0; i < out.length; i++) {
            out[i] = filteredList.get(i);
        }

        return out;
    } catch (Win32Exception e) {
        throw new DebuggableException(null, "(Try&catch try)", "Throw debuggable exception", "(End of function)",
                "Error reading registry", false, e);
    }
}
 
开发者ID:mob41,项目名称:osumer,代码行数:23,代码来源:Installer.java

示例2: checkKeyExists

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
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,代码行数:17,代码来源:LocalRegistryOperations.java

示例3: getHKey

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
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,代码行数:18,代码来源:LocalRegistryOperations.java

示例4: tryUpdateVIDPID

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
private void tryUpdateVIDPID(Disk disk) {
    try {
        final String USB_DEVICES_KEY = "SYSTEM\\CurrentControlSet\\Enum\\USB";
        String[] deviceKeys = Advapi32Util.registryGetKeys(WinReg.HKEY_LOCAL_MACHINE, USB_DEVICES_KEY);
        for (String deviceKey : deviceKeys) {
            if (deviceKey.startsWith("VID")) {
                if (Arrays.asList(
                        Advapi32Util.registryGetKeys(WinReg.HKEY_LOCAL_MACHINE, USB_DEVICES_KEY + "\\" + deviceKey))
                        .contains(disk.physicalSerial)) {
                    disk.VID = deviceKey.substring(4, 8);
                    disk.PID = deviceKey.substring(13, 17);
                }
            }
        }
    }
    catch (Exception e) {
        Logging.log("Unable to retrieve VID/PID for disk " + disk.model, LogMessageType.INFO);
        Logging.log(e);
    }
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:21,代码来源:DeviceManager.java

示例5: tryUpdateVendor

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
private void tryUpdateVendor(Disk disk) {
    try {
        final String USB_DEVICES_KEY = "SYSTEM\\CurrentControlSet\\Enum\\USBSTOR";
        String[] deviceKeys = Advapi32Util.registryGetKeys(WinReg.HKEY_LOCAL_MACHINE, USB_DEVICES_KEY);
        for (String deviceKey : deviceKeys) {
            if (deviceKey.startsWith("Disk")) {
                if (Arrays
                        .asList(Advapi32Util.registryGetKeys(WinReg.HKEY_LOCAL_MACHINE,
                                USB_DEVICES_KEY + "\\" + deviceKey))
                        .stream().anyMatch((x) -> x.contains(disk.physicalSerial))) {
                    int startIndex = deviceKey.indexOf("_");
                    if (startIndex != -1) {
                        disk.vendorName = deviceKey.substring(startIndex + 1, deviceKey.indexOf("&", startIndex));
                    }
                }
            }
        }
    }
    catch (Exception e) {
        Logging.log("Unable to retrieve vendor name for disk " + disk.model, LogMessageType.DEBUG);
        Logging.log(e);
    }
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:24,代码来源:DeviceManager.java

示例6: findBrowsersInRegistry

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
private static List<String> findBrowsersInRegistry() {
	// String regPath = "SOFTWARE\\Clients\\StartMenuInternet\\";
	String regPath = is64bit
			? "SOFTWARE\\Wow6432Node\\Clients\\StartMenuInternet\\"
			: "SOFTWARE\\Clients\\StartMenuInternet\\";

	List<String> browsers = new ArrayList<>();
	String path = null;
	try {
		for (String browserName : Advapi32Util
				.registryGetKeys(WinReg.HKEY_LOCAL_MACHINE, regPath)) {
			path = Advapi32Util
					.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE,
							regPath + "\\" + browserName + "\\shell\\open\\command", "")
					.replace("\"", "");
			if (path != null && new File(path).exists()) {
				System.err.println("Browser path: " + path);
				browsers.add(path);
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return browsers;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:26,代码来源:OSUtils.java

示例7: getRegistryRootKey

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
/**
 * Gets one of the root keys.
 * 
 * @param key
 *            key type
 * @return root key
 */
private static HKEY getRegistryRootKey(REGISTRY_ROOT_KEY key)
{
	Advapi32 advapi32;
	HKEYByReference pHandle;
	HKEY handle = null;

	advapi32 = Advapi32.INSTANCE;
	pHandle = new WinReg.HKEYByReference();

	if (advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WINERROR.ERROR_SUCCESS)
	{
		handle = pHandle.getValue();
	}
	return (handle);
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:23,代码来源:Registry.java

示例8: getVLCRegistryInfo

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
protected void getVLCRegistryInfo() {
	String key = "SOFTWARE\\VideoLAN\\VLC";
	try {
		if (!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, key)) {
			key = "SOFTWARE\\Wow6432Node\\VideoLAN\\VLC";
			if (!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, key)) {
				return;
			}
		}
		vlcPath = Paths.get(Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, key, ""));
		vlcVersion = new Version(Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, key, "Version"));
	} catch (Win32Exception e) {
		LOGGER.debug("Could not get VLC information from Windows registry: {}", e.getMessage());
		LOGGER.trace("", e);
	}
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:17,代码来源:WinUtils.java

示例9: getAviSynthPluginsFolder

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
protected String getAviSynthPluginsFolder() {
	String key = "SOFTWARE\\AviSynth";
	try {
		if (!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, key)) {
			key = "SOFTWARE\\Wow6432Node\\AviSynth";
			if (!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, key)) {
				return null;
			}
		}
		return Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, key, "plugindir2_5");
	} catch (Win32Exception e) {
		LOGGER.debug("Could not get AviSynth information from Windows registry: {}", e.getMessage());
		LOGGER.trace("", e);
	}
	return null;
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:17,代码来源:WinUtils.java

示例10: getKLiteFiltersFolder

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
protected String getKLiteFiltersFolder() {
	String key = "SOFTWARE\\Wow6432Node\\KLCodecPack";
	try {
		if (!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, key)) {
			key = "SOFTWARE\\KLCodecPack";
			if (!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, key)) {
				return null;
			}
		}
		return Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, key, "installdir");
	} catch (Win32Exception e) {
		LOGGER.debug("Could not get K-Lite Codec Pack information from Windows registry: {}", e.getMessage());
		LOGGER.trace("", e);
	}
	return null;
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:17,代码来源:WinUtils.java

示例11: getLocationFromInstallerValue

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
private static String getLocationFromInstallerValue()
        throws RegistryCanNotReadInfoException {
    String path;
    String pathValue;
    pathValue = getUninstallLocationForCurrentSystemArch();

    try {
        path = WinReg.HKEY_LOCAL_MACHINE + "\\" +
                pathValue + "\\" +
                RegistryManager.KEY_INSTALL_LOCATION;
        System.out.println("Default installer value:" + path);
        path = Advapi32Util
                .registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE,
                        pathValue,
                        RegistryManager.KEY_INSTALL_LOCATION);
        System.out.println("Default installer path: '" + path + "'");

    } catch (Exception e) {
        final String message = "Can not read value from Windows UnInstaller: " + "HKLM\\" +
                pathValue;
        log.warn(message, e);
        throw new RegistryCanNotReadInfoException(
                message, e);
    }
    return path;
}
 
开发者ID:benchdoos,项目名称:WeblocOpener,代码行数:27,代码来源:RegistryFixer.java

示例12: doesKeyNeedUpdated

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
/**
 * Check if registry keys exist and if the cmd file the key contains matches the latest cmd file
 *
 * @param newCmd
 * @return if keys exists or not
 */
protected static boolean doesKeyNeedUpdated(final File newCmd) throws IOException {
    try {
        final String existingKey = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, VSOI_KEY, StringUtils.EMPTY);
        final File existingCmd = new File(existingKey.replace("\"%1\"", "").trim());
        if (!existingCmd.exists()) {
            logger.debug("The registry key needs updated because the old key cmd file doesn't exist.");
            return true;
        }

        if (existingCmd.getPath().equalsIgnoreCase(newCmd.getPath()) || FileUtils.contentEquals(existingCmd, newCmd)) {
            logger.debug("The registry key does not need updated because {}", existingCmd.getPath().equalsIgnoreCase(newCmd.getPath()) ?
                    "the file paths are the same" : "the contents of the files are the same.");
            return false;
        }

        // use the newest cmd file so update if existing cmd file is older
        // TODO: version cmd file if we continually iterate on it so we chose the correct file more reliably
        logger.debug("The existing cmd file is {} old and the the cmd file is {} old", existingCmd.lastModified(), newCmd.lastModified());
        return existingCmd.lastModified() < newCmd.lastModified() ? true : false;
    } catch (Win32Exception e) {
        // Error occurred reading the registry (possible key doesn't exist or is empty) so update just to be safe
        logger.debug("There was an issue reading the registry so updating the key to be safe.");
        return true;
    }
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:32,代码来源:WindowsStartup.java

示例13: doApplySize

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
@Override
protected void doApplySize(final Size size) throws BotConfigurationException {
    final int width = size.x();
    final int height = size.y();
    final HKEYByReference key = Advapi32Util.registryGetKey(WinReg.HKEY_LOCAL_MACHINE,
            "SOFTWARE\\BlueStacks\\Guests\\Android\\FrameBuffer\\0", WinNT.KEY_READ | WinNT.KEY_WRITE);
    final int w1 = Advapi32Util.registryGetIntValue(key.getValue(), "WindowWidth");
    final int h1 = Advapi32Util.registryGetIntValue(key.getValue(), "WindowHeight");
    final int w2 = Advapi32Util.registryGetIntValue(key.getValue(), "GuestWidth");
    final int h2 = Advapi32Util.registryGetIntValue(key.getValue(), "GuestHeight");
    if (w1 != width || h1 != height || w2 != width || h2 != height) {
        Advapi32Util.registrySetIntValue(key.getValue(), "WindowWidth", width);
        Advapi32Util.registrySetIntValue(key.getValue(), "WindowHeight", height);
        Advapi32Util.registrySetIntValue(key.getValue(), "GuestWidth", width);
        Advapi32Util.registrySetIntValue(key.getValue(), "GuestHeight", height);
        Advapi32Util.registrySetIntValue(key.getValue(), "FullScreen", 0);
    }
    throw new BotConfigurationException(String.format("Please restart %s to fix resolution", BS_WINDOW_NAME));
}
 
开发者ID:paspiz85,项目名称:nanobot,代码行数:20,代码来源:BlueStacksWinPlatform.java

示例14: getApm

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
/**
 * Returns the current APM originating from the Windows Registry.
 * 
 * Note: since 2.0 SC2 outputs real-time APM instead of game-time APM,
 * so no conversion is performed to convert it anymore.
 * 
 * <p><b>How to interpret the values in the registry?</b><br>
 * The digits of the result: 5 has to be subtracted from the first digit (in decimal representation), 4 has to be subtracted from the second digit,
 * 3 from the third etc.
 * If the result of a subtraction is negative, 10 has to be added.
 * Examples: 64 => 10 APM; 40 => 96 APM; 8768 => 3336 APM; 38 => 84 APM</p>
 * 
 * @return the current APM or <code>null</code> if some error occurs 
 */
public static Integer getApm() {
	try {
		final String apmString = Advapi32Util.registryGetStringValue( WinReg.HKEY_CURRENT_USER, "Software\\Razer\\Starcraft2", "APMValue" );
		int apm = 0;
		
		for ( int idx = 0, delta = 5, digit; idx < apmString.length(); idx++, delta-- ) {
			digit = apmString.charAt( idx ) - '0' - delta;
			if ( digit < 0 )
				digit += 10;
			apm = apm * 10 + digit;
		}
		
		return apm;
	} catch ( final Exception e ) {
		// Silently ignore, do not print stack trace
		return null;
	}
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:33,代码来源:Sc2RegMonitor.java

示例15: findMobileLibrary

import com.sun.jna.platform.win32.WinReg; //导入依赖的package包/类
private static String findMobileLibrary() {
	if (Platform.isWindows()) {
		String path;
	    try {
	    	path = getMDPath(true);
	    	path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "iTunesMobileDeviceDLL");
	    } catch (Exception ignored) {
	    	try {
		    	path = getMDPath(false);
		    	path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "iTunesMobileDeviceDLL");
	    	} catch (Exception ignored1) {
	    		log.info(ignored.getMessage());
	    		return "";
	    	}
		}
    	File f = new File(path);
    	if (f.exists())
    		return path;
	} else {
		if (Platform.isMac()) {
			return "/System/Library/PrivateFrameworks/MobileDevice.framework/MobileDevice";
		}
	}
	return "";
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:26,代码来源:LibraryFinder.java


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