I am working on getting and setting registry values in Windows Forms.
My code looks like this:
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("SmogUser");
if (((Guid)key.GetValue("DeviceId", Guid.Empty)) == Guid.Empty)
{
Guid deviceId = Guid.NewGuid();
key.SetValue("DeviceId", deviceId);
key.Close();
}
else
{
Guid deviceId = (Guid)key.GetValue("DeviceId");
}
When I run the program the first time, it enters into the if clause and sets deviceId
,
but when I run the second time, the program is not continuing and there is no exception.
What is the problem?