Ehi, come può scorrere il registro usando C#? Vorrei creare una struttura per rappresentare gli attributi di ciascuna chiave.C# Come faccio a scorrere il registro?
risposta
Partenza questa funzione da MSDN: http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.getsubkeynames.aspx?PHPSESSID=ca9tbhkv7klmem4g3b2ru2q4d4
Questa funzione recupera il nome di tutte le sottochiavi e si può scorrere attraverso di loro e fare tutto ciò che si desidera.
È possibile utilizzare Microsoft.Win32.RegistryKey
e il metodo GetSubKeyNames
come descritto qui:
http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey_members%28v=VS.100%29.aspx
essere consapevoli però che questo potrebbe essere molto lento se si sta scorrendo gran parte del Registro di sistema.
Penso che quello che ti serve sia GetSubKeyNames()
come in questo esempio.
private void GetSubKeys(RegistryKey SubKey)
{
foreach(string sub in SubKey.GetSubKeyNames())
{
MessageBox.Show(sub);
RegistryKey local = Registry.Users;
local = SubKey.OpenSubKey(sub,true);
GetSubKeys(local); // By recalling itself it makes sure it get all the subkey names
}
}
//This is how we call the recursive function GetSubKeys
RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(@".DEFAULT\test",true);
GetSubKeys(OurKey);
(NOTA: Questo è stato originale copiata da un tutorial http://www.csharphelp.com/2007/01/registry-ins-and-outs-using-c/, ma il sito ora sembra essere verso il basso).
Grazie Chris! Stavo per scrivere una funzione arecursiva ma non ho familiarità con i metodi! Grazie – Tom
private void GetSubKeys(RegistryKey SubKey)
{
foreach(string sub in SubKey.GetSubKeyNames())
{
MessageBox.Show(sub);
RegistryKey local = Registry.Users;
local = SubKey.OpenSubKey(sub,true);
GetSubKeys(local); // By recalling itselfit makes sure it get all the subkey names
}
}
//This is how we call the recursive function GetSubKeys
RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(@".DEFAULT\test",true);
GetSubKeys(OurKey);
http://www.csharphelp.com/2007/01/registry-ins-and-outs-using-c/
- 1. come faccio a scorrere le proprietà interne in C#
- 2. Come faccio a scorrere su un vettore di stringhe C++?
- 3. Come faccio a far scorrere un tavolo
- 4. Come faccio a forzare JScrollPane a scorrere solo in verticale?
- 5. jQuery: come faccio a scorrere tutti gli elementi 'a'?
- 6. Come faccio a scorrere l'alfabeto in Python, per favore?
- 7. Come faccio a scorrere questo oggetto JSON in jQuery?
- 8. iOS: Come faccio a scorrere tra le visualizzazioni utilizzando Swift
- 9. Android - Come faccio a far scorrere questo messaggio di avviso?
- 10. Come faccio a smettere di scorrere automaticamente nel mio flexslider
- 11. Come faccio a scorrere gli oggetti figli in javascript?
- 12. come faccio a scorrere i campi di un oggetto?
- 13. Come faccio a scorrere i membri della classe?
- 14. Come faccio a scorrere i tag in un messaggio jekyll?
- 15. Come faccio a scorrere un oggetto SimpleXML in PHP
- 16. Come faccio a far scorrere UIWebView verso l'alto?
- 17. Come faccio a confrontare le versioni del registro in WiX?
- 18. Come faccio a scorrere tutti i file in una cartella usando C?
- 19. Come faccio a scorrere le proprietà di un oggetto anonimo in C#?
- 20. Come faccio a scorrere l'UITableView verso il basso per rivelare il sottostante UIRefreshControl
- 21. Come scorrere fino a elemento con Selenium WebDriver usando C#
- 22. Come faccio a utilizzare errno in C++
- 23. Come faccio a chiamare il costruttore giusto?
- 24. Come faccio a rebase il primo commit?
- 25. Utilizzo di C++ per modificare il registro
- 26. Come faccio a scorrere un ScrollViewer in Design Time in Blend
- 27. Come faccio a far scorrere la mia app oltre qualcosa coperto dalla tastiera
- 28. Come faccio a scorrere un file, byte per byte, in JavaScript?
- 29. Come faccio a scorrere le righe e le celle della tabella in JavaScript?
- 30. Come faccio a scorrere ogni elemento in una matrice n-dimensionale in MATLAB?
Questo romperà ogni portabilità con Mono su altri sistemi oltre a Windows. Solo un avvertimento – alternative