Registry Help

joe_pool_is

Contributor
Joined
Jan 18, 2004
Messages
507
Location
Longview, TX [USA]
I have tried writing values to the Registry below. Even though the Registry Key "rk" is non-NULL, inspecting the Registry afterwards in the HKCU Software section does not show any new settings.

Can the Registry be modified in Visual C++ 2005 Express (i.e. CLR)?

I tried this code (actually C++ code, not CS):
C#:
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
String^ strKey;
strKey = "Software\\Slick Co\\FancySoft 2";
RegistryKey^ rk = nullptr;
rk = Registry::CurrentUser->OpenSubKey(strKey);
if (rk) {
rk->Close();
}
}
 
protected:
~Form1()
{
String^ strKey;
strKey = "Software\\Slick Co\\FancySoft 2";
RegistryKey^ rk = nullptr;
rk = Registry::CurrentUser->OpenSubKey(strKey, true);
if (!rk)
{
rk->CreateSubKey(strKey);
}
if (rk)
{
rk->Close();
}
if (components)
{
delete components;
}
}
 
I see no reason why this should not work. I'm not trying to call you stupid, but you have refreshed regedit after you ran the code, right? No exceptions being thrown? You have the necessary permissions? And your positive that the form is being disposed (destructed)? Have you tried verifying the results in code (re-read the registry key, show result in messagebox or w/e)?
 
Back
Top