C++ .NET and Windows Registry

Started by
14 comments, last by PyroBlizzard 18 years, 10 months ago
Quote:void RetrieveKeys(RegistryKey^ rKey)
{
//Retrieve all subkeys for given key
System::String^ directory = rKey->GetValue("InstallPath")->ToString();
MessageBox::Show(directory);
}


Ok, so I have it getting the correct key information now, but how would I go about sending that string (directory) to a textbox? Keep in mind, im using C++\CLI code
As I lay down, staring up at the stars in all their glory, I wonder.....WHERE THE F*** IS MY ROOF!?!?!?
Advertisement
Anybody got a thought? Im really getting into this program, I dont wanna have to stop cause of lack of knowledge.
As I lay down, staring up at the stars in all their glory, I wonder.....WHERE THE F*** IS MY ROOF!?!?!?
Well, I set tWoWDir to public, and when going to access the text field, I do

Quote:
Form1::tWoWDir


And thats as far as I can go with intellisense. And I get an error when I try to do

Quote:
Form1::tWoWDir::Text = directory;

.\WarMiner.cpp(17) : error C3083: 'tWoWDir': the symbol to the left of a '::' must be a type
.\WarMiner.cpp(17) : error C2597: illegal reference to non-static member 'System::Windows::Forms::Form::Text'

or
Quote:
Form1::tWoWDir->Text = directory;

.\WarMiner.cpp(17) : error C2227: left of '->Text' must point to class/struct/union/generic type
As I lay down, staring up at the stars in all their glory, I wonder.....WHERE THE F*** IS MY ROOF!?!?!?
tWoWDir a an instance variable, in order to access it you must access it through an instance of Form1:
Form1^ f = new Form1();f->tWowDir = "Rawr";


If you already have an instance created (I would assume as much, but hey, you never know) then use that instance instead of creating a new one.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Ok, thank you SO much for that. I got alittle progress, and I will continue working on this as well, but here is the issue.

It compiled with this code

Quote:
void RetrieveKeys()
{
RegistryKey^ localMachine = Registry::LocalMachine;
RegistryKey^ software = localMachine->OpenSubKey("SOFTWARE\\Blizzard Entertainment\\World of Warcraft");
System::String^ directory = software->GetValue("InstallPath")->ToString();
fWarMiner^ mainForm = gcnew fWarMiner();
mainForm->tWoWDir->Text = directory;
}

int main(array<System::String ^> ^args)
{
// Grabbing registry value for World of Warcraft Directory
RetrieveKeys();

// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualstyles();

// Create the main window and run it
Application::Run(gcnew fWarMiner());
return 0;
}


But, the actual text of tWoWDir was still blank (though I know im getting the value of the registry key, because I had a messagebox set to pop up with the value of directory in it. Now, is it a problem that im doing the line

Quote:fWarMiner^ mainForm = gcnew fWarMiner();


then running

Quote:Application::Run(gcnew fWarMiner());


Which seems to be making a new form
As I lay down, staring up at the stars in all their glory, I wonder.....WHERE THE F*** IS MY ROOF!?!?!?
Figured it out :D
As I lay down, staring up at the stars in all their glory, I wonder.....WHERE THE F*** IS MY ROOF!?!?!?

This topic is closed to new replies.

Advertisement