"Insufficient memory to continue the execution of the program" exception
All I'm trying to do is open a registry subkey and read a value. Oddly, the same application works on other windows systems. I'm just concerned about this - want to make sure its not something in my application.
Mine is a winforms application developed using managed C++. Is there something wrong with my app?
Here's the code that gets the registry key -
// Check for Registry Key to make sure iscsi iqn number is set.
RegistryKey ^LocalMachine;
RegistryKey ^iqnKey;
bool keyfound =false;try{
// Specify the HKEY_LOCAL_MACHINE hiveLocalMachine = Registry::LocalMachine;
iqnKey = LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\XXX\\Default");// Request all values from the "Default Folder" keyarray <String^> ^valueNames = iqnKey->GetValueNames();// Enumerate the valuesfor (int i = 0; i < valueNames->Length; i++){
// Each value name is now represented by valueNamesString ^value =
static_cast<String^>(iqnKey->GetValue(valueNames{
keyfound =
true;}
}
if (!keyfound){
MessageBox::Show(
"Application cannot function correctly as the XXX Registry Key was not found.","XXX Key Error", MessageBoxButtons::OK, MessageBoxIcon::Error);return -1;}
}
catch(Exception ^ex){
MessageBox::Show(
ex->Message,"Exception Occurred", MessageBoxButtons::OK, MessageBoxIcon::Error);return -1;}
__finally{
if (iqnKey) iqnKey->Close();if (LocalMachine) LocalMachine->Close();}

