本文整理汇总了Java中com.sun.jna.platform.win32.Advapi32Util类的典型用法代码示例。如果您正苦于以下问题:Java Advapi32Util类的具体用法?Java Advapi32Util怎么用?Java Advapi32Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Advapi32Util类属于com.sun.jna.platform.win32包,在下文中一共展示了Advapi32Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvailableBrowsers
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的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);
}
}
示例2: getIntValue
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Get Integer registry value(REG_DWORD)
*
* @param keyPath
* @param keyName
* @return
*/
@Override
public int getIntValue(
String rootKey,
String keyPath,
String keyName ) {
checkKeyExists(rootKey, keyPath, keyName);
try {
return Advapi32Util.registryGetIntValue(getHKey(rootKey), keyPath, keyName);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Registry key is not of type Integer. "
+ getDescription(rootKey, keyPath, keyName), re);
}
}
示例3: getLongValue
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Get Long registry value(REG_QWORD)
*
* @param keyPath
* @param keyName
* @return
*/
@Override
public long getLongValue(
String rootKey,
String keyPath,
String keyName ) {
checkKeyExists(rootKey, keyPath, keyName);
try {
return Advapi32Util.registryGetLongValue(getHKey(rootKey), keyPath, keyName);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Registry key is not of type Long. "
+ getDescription(rootKey, keyPath, keyName), re);
}
}
示例4: getBinaryValue
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Get Binary registry value(REG_BINARY)
*
* @param keyPath
* @param keyName
* @return
*/
@Override
public byte[] getBinaryValue(
String rootKey,
String keyPath,
String keyName ) {
checkKeyExists(rootKey, keyPath, keyName);
try {
return Advapi32Util.registryGetBinaryValue(getHKey(rootKey), keyPath, keyName);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Registry key is not of type Binary. "
+ getDescription(rootKey, keyPath, keyName), re);
}
}
示例5: createPath
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Creates path in the registry.
*
* Will fail if the path exists already.
*
* If want to create a nested path(for example "Software\\MyCompany\\MyApplication\\Configuration"),
* it is needed to call this method for each path token(first for "Software\\MyCompany", then for "Software\\MyCompany\\MyApplication" etc)
*
* @param keyPath
*/
@Override
public void createPath(
String rootKey,
String keyPath ) {
log.info("Create regestry key path: " + getDescription(rootKey, keyPath, null));
int index = keyPath.lastIndexOf("\\");
if (index < 1) {
throw new RegistryOperationsException("Invalid path '" + keyPath + "'");
}
String keyParentPath = keyPath.substring(0, index);
String keyName = keyPath.substring(index + 1);
checkPathDoesNotExist(rootKey, keyPath);
try {
Advapi32Util.registryCreateKey(getHKey(rootKey), keyParentPath, keyName);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Couldn't create registry key. "
+ getDescription(rootKey, keyPath, keyName), re);
}
}
示例6: setStringValue
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Applies a String(REG_SZ) value on the specified key.
*
* The key will be created if does not exist.
* The key type will be changed if needed.
*
* @param keyPath
* @param keyName
* @param keyValue
*/
@Override
public void setStringValue(
String rootKey,
String keyPath,
String keyName,
String keyValue ) {
log.info("Set String value '" + keyValue + "' on: " + getDescription(rootKey, keyPath, keyName));
try {
Advapi32Util.registrySetStringValue(getHKey(rootKey), keyPath, keyName, keyValue);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Couldn't set registry String value '" + keyValue
+ "' to: "
+ getDescription(rootKey, keyPath, keyName),
re);
}
}
示例7: setIntValue
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Applies a Integer(REG_DWORD) value on the specified key.
*
* The key will be created if does not exist.
* The key type will be changed if needed.
*
* @param keyPath
* @param keyName
* @param keyValue
*/
@Override
public void setIntValue(
String rootKey,
String keyPath,
String keyName,
int keyValue ) {
log.info("Set Intger value '" + keyValue + "' on: " + getDescription(rootKey, keyPath, keyName));
try {
Advapi32Util.registrySetIntValue(getHKey(rootKey), keyPath, keyName, keyValue);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Couldn't set registry Integer value '" + keyValue
+ "' to: "
+ getDescription(rootKey, keyPath, keyName),
re);
}
}
示例8: setLongValue
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Applies a Long(REG_QWORD) value on the specified key.
*
* The key will be created if does not exist.
* The key type will be changed if needed.
*
* @param keyPath
* @param keyName
* @param keyValue
*/
@Override
public void setLongValue(
String rootKey,
String keyPath,
String keyName,
long keyValue ) {
log.info("Set Long value '" + keyValue + "' on: " + getDescription(rootKey, keyPath, keyName));
try {
Advapi32Util.registrySetLongValue(getHKey(rootKey), keyPath, keyName, keyValue);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Couldn't set registry Long value '" + keyValue + "' to: "
+ getDescription(rootKey, keyPath, keyName), re);
}
}
示例9: setBinaryValue
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Applies a Binary(REG_BINARY) value on the specified key.
*
* The key will be created if does not exist.
* The key type will be changed if needed.
*
* @param keyPath
* @param keyName
* @param keyValue
*/
@Override
public void setBinaryValue(
String rootKey,
String keyPath,
String keyName,
byte[] keyValue ) {
log.info("Set Binary value '" + Arrays.toString(keyValue) + "' on: "
+ getDescription(rootKey, keyPath, keyName));
try {
Advapi32Util.registrySetBinaryValue(getHKey(rootKey), keyPath, keyName, keyValue);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Couldn't set registry binary value to: "
+ getDescription(rootKey, keyPath, keyName), re);
}
}
示例10: deleteKey
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的package包/类
/**
* Delete a registry key
*
* @param keyPath
* @param keyName
*/
@Override
public void deleteKey(
String rootKey,
String keyPath,
String keyName ) {
log.info("Delete key: " + getDescription(rootKey, keyPath, keyName));
try {
Advapi32Util.registryDeleteValue(getHKey(rootKey), keyPath, keyName);
} catch (RuntimeException re) {
throw new RegistryOperationsException("Couldn't delete registry key. "
+ getDescription(rootKey, keyPath, keyName), re);
}
}
示例11: checkKeyExists
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的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);
}
}
示例12: tryUpdateVIDPID
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的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);
}
}
示例13: tryUpdateVendor
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的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);
}
}
示例14: findBrowsersInRegistry
import com.sun.jna.platform.win32.Advapi32Util; //导入依赖的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;
}
示例15: 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);
}
}