The following code example uses the
Example
В | ![]() |
---|---|
// registry_read.cpp // compile with: /clr using namespace System; using namespace Microsoft::Win32; int main( ) { array<String^>^ key = Registry::CurrentUser->GetSubKeyNames( ); Console::WriteLine("Subkeys within CurrentUser root key:"); for (int i=0; i<key->Length; i++) { Console::WriteLine(" {0}", key[i]); } Console::WriteLine("Opening subkey 'Identities'..."); RegistryKey^ rk = nullptr; rk = Registry::CurrentUser->OpenSubKey("Identities"); if (rk==nullptr) { Console::WriteLine("Registry key not found - aborting"); return -1; } Console::WriteLine("Key/value pairs within 'Identities' key:"); array<String^>^ name = rk->GetValueNames( ); for (int i=0; i<name->Length; i++) { String^ value = rk->GetValue(name[i])->ToString(); Console::WriteLine(" {0} = {1}", name[i], value); } return 0; } |
Remarks
The
In addition to being static, the objects within the Registry class are read-only. Furthermore, instances of the
There are two additional objects in the Registry class:
See Also
Concepts
How to: Write Data to the Windows RegistryOther Resources
Windows Operations in C++.NET Programming in C++