Hi guys,
I'm trying to delete a registry key in windows mobile
I've tryed looking the code on google
(c# delete registry key value)[
^]
A lot of info is provided, but it doen't get me to solve it.
I tried
http://www.codeproject.com/KB/system/modifyregistry.aspx
But didn't get it to work
I got it to write a key, check if a key is there
But I get exceptions when deleting.
I'm using visual Studio 2008 pro writing a app. for smart device in C#
I'm am new to programming but got an app up and running by studing home and learn website , copy and editing code provided at internet (msdn, codeproject, google etc)
I want do use the registry, so I created a test app. to test write/read and delete Registry keys/values.
Is there someone who can provide a working code?
I can provide the source file (project) if handy?
Thankz in advance
Code underneath:
Button1: write key
Button2: checks key is prsent
Button3 should delete key.
I think I need an overloador something
(I dont know what an overload is, Im not a programmer,
trying to get somewhere, but watching, using, modifying and thus learning)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace RegistryKeys_TEST
{
public partial class Frm_REG_TEST : Form
{
public Frm_REG_TEST()
{
InitializeComponent();
}
private void btn_write_key_Click(object sender, EventArgs e)
{
RegistryKey versie1 = Registry.LocalMachine.CreateSubKey("SOFTWARE\\test\\DeleteMe");
versie1.Close();
}
private void btn_rk_exist_Click(object sender, EventArgs e)
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey("Software\\test\\DeleteMe");
if (rk != null)
{
MessageBox.Show("YES");
}
else
{
MessageBox.Show("NO");
}
}
private void REG_TEST_L_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void REG_TEST_R_form2_Click(object sender, EventArgs e)
{
Form2 nogeenform = new Form2();
nogeenform.Show();
}
private void btn_del_key_Click(object sender, EventArgs e)
{
RegistryKey versie1 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\test");
versie1.DeleteSubKeyTree("DeleteMe");
versie1.Close();
}
}
}
Regards,
Frans