本文整理汇总了Java中com.sun.jna.platform.win32.Advapi32Util.registryCreateKey方法的典型用法代码示例。如果您正苦于以下问题:Java Advapi32Util.registryCreateKey方法的具体用法?Java Advapi32Util.registryCreateKey怎么用?Java Advapi32Util.registryCreateKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.platform.win32.Advapi32Util
的用法示例。
在下文中一共展示了Advapi32Util.registryCreateKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: writeToKey
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
private static void writeToKey(int value) {
try {
if (!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, WRITE_BLOCK_KEY)) {
Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, WRITE_BLOCK_KEY);
}
Advapi32Util.registrySetIntValue(WinReg.HKEY_LOCAL_MACHINE, WRITE_BLOCK_KEY, "WriteProtect", value);
}
catch (IllegalArgumentException e) {
Logging.log("Failed to " + (value == 0 ? "disable" : "enable") + " USB write block", LogMessageType.WARNING);
Logging.log(e);
}
}
示例3: createRootRegistryFolder
import com.sun.jna.platform.win32.Advapi32Util; //导入方法依赖的package包/类
public static void createRootRegistryFolder(String path) throws RegistryCanNotWriteInfoException {
if (!Advapi32Util.registryKeyExists(APP_ROOT_HKEY, path)) {
try {
Advapi32Util.registryCreateKey(APP_ROOT_HKEY, path);
} catch (Win32Exception e) {
throw new RegistryCanNotWriteInfoException("Can not create root folder on registry.", e);
}
}
}