本文介绍了无法使用CRegKey打开HKEY_LOCAL_MACHINE \\ SOFTWARE密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想要做的就是检查密钥HKEY_LOCAL_MACHINE \\ SOFTWARE \\GITSourceControl 如果它们不存在那么我想创建密钥GITSourceControl和值'email'和'username'。 但遗憾的是我甚至无法打开现有密钥'HKEY_LOCAL_MACHINE \\ SOFTWARE'并且我不知道为什么它不起作用。 我在下面做错了什么? CRegKey RegKey; if(RegKey.Open(HKEY_LOCAL_MACHINE," SOFTWARE\\GITSourceControl"))!= ERROR_SUCCESS) { RegKey.Close(); if(RegKey.Open(HKEY_LOCAL_MACHINE," \\Software")== ERROR_SUCCESS) { lResult = RegKey.Create(HKEY_LOCAL_MACHINE," GITSourceControl"); ASSERT(lResult == ERROR_SUCCESS); RegKey.Close(); } } if(RegKey.Open(HKEY_LOCAL_MACHINE," SOFTWARE \\GITSourceControl")== ERROR_SUCCESS) { lResult = RegKey.SetStringValue ("电子邮件",strEmail); ASSERT(lResult == ERROR_SUCCESS); lResult = RegKey.SetStringValue(" Username",strUsername); ASSERT(lResult == ERROR_SUCCESS); } 其他 { ASSERT(false); } 解决方案 All I want to do is check for the presence of the registry values 'email' and 'username' under the key HKEY_LOCAL_MACHINE\\SOFTWARE\\GITSourceControlIf they are not present then I want to create the key GITSourceControl and the values 'email' and 'username'.But sadly I can't even open the existing key 'HKEY_LOCAL_MACHINE\\SOFTWARE' and I have no idea why it is not working.What am I doing wrong below?CRegKey RegKey;if (RegKey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\GITSourceControl") != ERROR_SUCCESS){RegKey.Close();if (RegKey.Open(HKEY_LOCAL_MACHINE, "\\Software") == ERROR_SUCCESS){lResult = RegKey.Create(HKEY_LOCAL_MACHINE, "GITSourceControl");ASSERT(lResult == ERROR_SUCCESS);RegKey.Close();}}if (RegKey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\GITSourceControl") == ERROR_SUCCESS){lResult = RegKey.SetStringValue("Email", strEmail);ASSERT(lResult == ERROR_SUCCESS);lResult = RegKey.SetStringValue("Username", strUsername);ASSERT(lResult == ERROR_SUCCESS);}else{ASSERT(false);} 解决方案 这篇关于无法使用CRegKey打开HKEY_LOCAL_MACHINE \\ SOFTWARE密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-24 17:47