Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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):

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;
}
}

  • Leaders
Posted
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)?
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...