简体   繁体   English

重新启动后删除注册表项

[英]Registry entry is deleted after reboot

I save directory path to registry with this code: 我使用以下代码将目录路径保存到注册表:

HKEY hKey;
RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\BArtWell\\MyApp", 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
RegSetValueEx(hKey,L"Directory",0,REG_SZ,(LPBYTE)sz,(DWORD)wcslen(sz)*sizeof(wchar_t));
RegCloseKey(hKey);

And it is working fine before reboot. 并且在重新启动之前它工作正常。 But after reboot path HKCU\\Software\\BArtWell\\MyApp doesn't exists. 但是,重新启动路径后,HKCU \\ Software \\ BArtWell \\ MyApp不存在。 Tested on XP and Windows7 with same result. 在XP和Windows7上进行测试,结果相同。 What I do wrong? 我做错了什么?

Read the documentation for REG_OPTION_VOLATILE . 阅读REG_OPTION_VOLATILE的文档。 Then replace it with 0. 然后将其替换为0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM