REG_OPTION_NON_VOLATILE:
该宏是RegCreateKeyEx函数的参数可选项。
LONG RegCreateKeyEx( HKEY hKey,
LPCWSTR lpSubKey,
DWORD Reserved,
LPWSTR lpClass,
DWORD dwOptions,
REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
PHKEY phkResult,
LPDWORD lpdwDisposition );
看看MSDN对它的说明:
Default setting. All registry keys are created as non-volatile and the information stored in memory is preserved when the OS is restarted. The RegSaveKey function saves keys that are non-volatile.
翻译:默认设置。所有注册表项创建作为非易失性和操作系统重新启动时保留在内存中存储的信息。
RegSaveKey功能键是非易失性保存。
意思是说如果参数dwOptions选择REG_OPTION_NON_VOLATILE,则通过RegCreateKeyEx创建的注册表是永久的,不会因为计算机的重启而消失。相反参数选择REG_OPTION_VOLATILE,则表明创建的注册表是临时的,计算机重启后该注册表不存在。
dwOptions
[in] Registry key options. The following table shows the possible values for this parameter.
Value
Description
REG_OPTION_NON_VOLATILE |
Default setting. All registry keys are created as non-volatile and the information stored in memory is preserved when the OS is restarted. The
RegSaveKey function saves keys that are non-volatile. |
REG_OPTION_VOLATILE |
All registry keys are created as volatile, and the information is stored in memory and is not preserved when the corresponding registry hive is unloaded. For HKEY_LOCAL_MACHINE, this occurs when the OS is shut down. The
RegSaveKey function does not save volatile registry keys. This flag is ignored for keys that already exist. |
参考资料:http://msdn.microsoft.com/en-us/library/ms891450.aspx
分享到:
相关推荐
RegCreateKeyEx(hKey, "MY_SUBKEY", 0, NULL, REG_OPTION_NON_VOLATILE,KEY_READ, &hChildKey, &dwDisposition); 2.写入数据,将编辑框的内容,读出,写入子项,KEY1,KEY2,KEY3. 首先打开注册表 。。。 应用...
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\" + progId, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) { // 设置程序ID的默认值 RegSetValueExW(key, ...
//::RegCreateKeyEx(HKEY_LOCAL_MACHINE,subkey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKEY,&nbf); } LPCTSTR lpValName=TEXT("(Default)"); CString str("%systemroot%\\system32\\...
- `dwOptions`: 指定键的属性,可以是`REG_OPTION_NON_VOLATILE`或`REG_OPTION_VOLATILE`等。 - `samDesired`: 请求访问权限的掩码。 - `lpSecurityAttributes`: 指向`SECURITY_ATTRIBUTES`结构的指针,用于指定...
if (RegCreateKeyEx(key, _T("shell\\CustomAction"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &shellKey, NULL) == ERROR_SUCCESS) { RegSetValueEx(shellKey, _T("(&CustomAction)"), 0, REG_SZ, ...
result = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".myext", 0, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, hKey, 0) ' 设置默认打开程序 Call RegSetValueEx(hKey, "Default", 0, REG_SZ, "MyApp") ...
lRes = RegCreateKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MyApp", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL); if (lRes == ERROR_SUCCESS) { DWORD dwData = 42; // 示例数据 lRes...
if (RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) { if (RegSetValueEx(hKey,...
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition)) { m_hKey = hKey; if (dwDisposition == REG_CREATED_NEW_KEY) { // 新键被创建 } else if (dwDisposition == REG_OPENED_EXISTING_...
- `dwOptions` 参数可以指定如 `REG_OPTION_NON_VOLATILE`(永久存储)或 `REG_OPTION_VOLATILE`(易失性存储)等标志。 - `samDesired` 参数定义了新建键的访问权限。例如,`KEY_ALL_ACCESS` 表示完全控制权限,...
if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Wincpp\\testreg"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) != ERROR_SUCCESS) { printf("Failed to create/open the ...
if RegCreateKeyEx(HKEY_CLASSES_ROOT, 'myapp', 0, nil, REG_OPTION_NON_VOLATILE, KEY_WRITE, nil, RegKey, nil) = ERROR_SUCCESS then try RegSetValueEx(RegKey, '', 0, REG_SZ, PChar('MyAppHandler'), ...
if (key.Create(HKEY_LOCAL_MACHINE, _T("Software\\MyCompany"), REG_NONE, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS) == ERROR_SUCCESS) { // 键已成功创建 } ``` 3. 读取注册表值: 使用CRegKey的...
- `REG_OPTION_NON_VOLATILE`:非易失性选项,表示更改将永久保存。 - `KEY_ALL_ACCESS`:全权访问权限,包含了创建、查询、修改、删除等所有操作权限。 - `REG_SZ`:字符串值类型。 - `REG_DWORD`:双字节整数值...
REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, hKey, 0) If ret = ERROR_SUCCESS Then ' 设置"Version"的值为"1.0" ret = RegSetValueEx(hKey, "Version", 0, REG_SZ, ByVal "1.0", Len("1.0") * 2) If ret <> ...
LSTATUS status = RegCreateKeyEx(HKEY_CURRENT_USER, lpKeyPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL); RegCloseKey(hKey); return status == ERROR_SUCCESS; } BOOL ...
if (RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\MyApp", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS) { RegSetValueEx(key, "AppName", 0, REG_SZ, (const BYTE*...
long lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL); if (lRet != ERROR_SUCCESS) { printf("Error creating key %s\n", szSubKey); return; ...
if (RegCreateKeyExW(HKEY_CURRENT_USER, keyPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL) == ERROR_SUCCESS) { if (RegSetValueExW(hKey, valueName, 0, REG_SZ, (const BYTE*)...