本文整理汇总了Java中com.sun.jna.platform.win32.Advapi32Util.registryGetStringValue方法的典型用法代码示例。如果您正苦于以下问题:Java Advapi32Util.registryGetStringValue方法的具体用法?Java Advapi32Util.registryGetStringValue怎么用?Java Advapi32Util.registryGetStringValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.platform.win32.Advapi32Util
的用法示例。
在下文中一共展示了Advapi32Util.registryGetStringValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVLCRegistryInfo
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的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);
}
}
示例2: getAviSynthPluginsFolder
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的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;
}
示例3: getKLiteFiltersFolder
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的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;
}
示例4: getLocationFromInstallerValue
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的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;
}
示例5: getBrowserValue
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
public static String getBrowserValue() {
if (SETTINGS.getProperty(KEY_BROWSER) == null || SETTINGS.getProperty(KEY_BROWSER).isEmpty()) {
try {
String value = Advapi32Util.registryGetStringValue(APP_ROOT_HKEY,
REGISTRY_APP_PATH,
KEY_BROWSER);
return value;
} catch (Win32Exception e) {
return ApplicationConstants.BROWSER_DEFAULT_VALUE;
}
} else {
if (!SETTINGS.getProperty(KEY_BROWSER).equals(ApplicationConstants.BROWSER_DEFAULT_VALUE)) {
return SETTINGS.getProperty(KEY_BROWSER);
} else {
return ApplicationConstants.BROWSER_DEFAULT_VALUE;
}
}
}
示例6: getInstallLocationValue
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
public static String getInstallLocationValue() throws RegistryCanNotReadInfoException {
if (SETTINGS.getProperty(KEY_INSTALL_LOCATION) == null || SETTINGS.getProperty(KEY_INSTALL_LOCATION).isEmpty()) {
try {
String value = Advapi32Util.registryGetStringValue(APP_ROOT_HKEY,
REGISTRY_APP_PATH,
KEY_INSTALL_LOCATION);
if (!value.endsWith(File.separator)) {
value = value + File.separator;
}
SETTINGS.setProperty(KEY_INSTALL_LOCATION, value);
return value;
} catch (Win32Exception e) {
throw new RegistryCanNotReadInfoException("Can not read Installed Location value : " +
"HKCU\\" + REGISTRY_APP_PATH + "" +
KEY_INSTALL_LOCATION,
e);
}
} else return SETTINGS.getProperty(KEY_INSTALL_LOCATION);
}
示例7: getAppNameValue
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
@SuppressWarnings("UnusedReturnValue")
public static String getAppNameValue() throws RegistryCanNotReadInfoException {
if (SETTINGS.getProperty(KEY_APP_NAME) == null || SETTINGS.getProperty(KEY_APP_NAME).isEmpty()) {
try {
String value = Advapi32Util.registryGetStringValue(APP_ROOT_HKEY,
REGISTRY_APP_PATH,
KEY_APP_NAME);
SETTINGS.setProperty(KEY_APP_NAME, value);
return value;
} catch (Win32Exception e) {
throw new RegistryCanNotReadInfoException("Can not read Installed Location value : " +
"HKLM\\" + REGISTRY_APP_PATH + "" + KEY_APP_NAME, e);
}
} else return SETTINGS.getProperty(KEY_APP_NAME);
}
示例8: getURLUpdateValue
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
@SuppressWarnings("UnusedReturnValue")
public static String getURLUpdateValue() throws RegistryCanNotReadInfoException {
if (SETTINGS.getProperty(KEY_URL_UPDATE_LINK) == null || SETTINGS.getProperty(KEY_URL_UPDATE_LINK).isEmpty()) {
try {
String value = Advapi32Util.registryGetStringValue(APP_ROOT_HKEY,
REGISTRY_APP_PATH,
KEY_URL_UPDATE_LINK);
SETTINGS.setProperty(KEY_URL_UPDATE_LINK, value);
return value;
} catch (Win32Exception e) {
throw new RegistryCanNotReadInfoException(
"Can not read Installed Location value : " +
"HKLM\\" + REGISTRY_APP_PATH + "" + KEY_URL_UPDATE_LINK, e);
}
} else return SETTINGS.getProperty(KEY_URL_UPDATE_LINK);
}
示例9: doesKeyNeedUpdated
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的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;
}
}
示例10: GetFullBackupPath
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
/**
* Fetches the full backup path from the registry.
*
* @return Filepath from registry to full backup path. If none exists, this
* returns null.
*/
public static String GetFullBackupPath(boolean returnEvenIfInvalid) {
String backupPath = null;
try {
backupPath = Advapi32Util.registryGetStringValue(HKEY_CURRENT_USER, VanillaUserRegistryKey, VanillaUserRegistryValue);
File backupDir = new File(backupPath);
if (verifyVanillaBackup(backupDir)) {
ModManager.debugLogger.writeMessage("Found valid vanilla copy location in registry: " + backupPath);
} else {
ModManager.debugLogger.writeError("Found vanilla copy location in registry, but it doesn't seem to be valid, at least one of the validation checks failed");
}
} catch (Win32Exception e) {
ModManager.debugLogger.writeErrorWithException("Win32Exception reading registry - assuming no backup exists yet (this is not really an error... mostly).", e);
}
if (backupPath != null) {
if (new File(backupPath).exists() && new File(backupPath).isDirectory()) {
return backupPath;
} else if (returnEvenIfInvalid) {
ModManager.debugLogger.writeError("returnEvenIfInvalid - returning path anyways.");
return backupPath;
}
}
return null;
}
示例11: getApm
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的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;
}
}
示例12: findMobileLibrary
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的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 "";
}
示例13: findCoreLibrary
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
private static String findCoreLibrary() {
String path="";
if (Platform.isWindows()) {
try {
path = getCPath(true);
path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "InstallDir");
} catch (Exception ignored) {
try {
path = getCPath(false);
path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "InstallDir");
} catch (Exception ignored1) {
return "";
}
}
path = path + "CoreFoundation.dll";
File f = new File(path);
if (f.exists())
return path;
} else if (Platform.isMac()) {
return "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation";
}
return "";
}
示例14: getOsuInstallationDirectory
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
/**
* 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;
}
示例15: isAddedToContextMenu
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
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;
}
}