Hey when ever i start debugging my program i get this one error that causes the program to crash. the error is :Object reference not set to an instance of an object
Here is the part of the code that needs to be seen:
I always get the error at the line:Code:Microsoft::Win32::RegistryKey^ key = Microsoft::Win32::Registry::CurrentUser->OpenSubKey( "Software\\Policies\\Microsoft\\Windows\\System\\DisableCMD"); System::Object^ result; result = key->GetValue("DisableCMD"); String^ val = result->ToString(); System::Windows::Forms::MessageBox::Show(val);
result = key->GetValue("DisableCMD");
Error:An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll
Additional information: Object reference not set to an instance of an object.
I checked to make sure the value existed and it did, but even if the value doesn't exist, i thought it would just set the variable equal to 'null' but maybe i am wrong. if someone could help me with this problem i would be very grateful.