Is it possible to export registry keys?

15/02/2007 - 03:01 por Ted E. | Informe spam
First of all, I'm about as new to C# as you can get, so go easy on me.
I'm using Visual Studio 2005 and programming in C#.

I searched the internet high and low to find a simple way to export a
registry key to a .reg file (as if done using regedit.exe/export
function), but what I'm finding is that it is not possible as far as C#
having a method to do so. The only alternatives I can see are using a
batch file to do the exporting (I am currently doing it this way), using
another language to do the exporting (not desirable to me), or readng
each of the keys/subkeys' values and saving to the text (.reg) file that
way. Am I missing something or are these the only alternatives I have?

If it helps, I'm trying to make a back up program (console, not Windows)
to back up certain files, folders, and registry keys as well as download
and save a couple files from online for my own personal use. Right now,
I'm keeping things "simple" and hardcoding the file names/paths/etc.,
but if I can find an easy way to export the registry keys in C#, I'll
elaborate on the program and use a form and add more flexibility to it.

So, if there is a way to easily export a key (such as
HKCU\Software\Microsoft\Windows\CurrentVersion\Run) then please give me
a hint. No direct code samples as I really want to learn this on my
own.

Thank you.

*** Sent via Developersdex http://www.developersdex.com ***
 

Leer las respuestas

#1 Octavio Hernandez
15/02/2007 - 12:24 | Informe spam
Hola,

En el lenguaje del foro, creo q deberías utilizar "flujo" en vez de "stream"
;-)

Slds - Octavio


En el lenguaje del foro,

Utilizar la clase RegistryKey para leer los valores del registro y las
clases de System.IO como StreamWriter u otras para escribir dichos valores
a
un stream.


It should be relatively straightforward to code. Just use the
RegistryKey
class to read the values from the registry, and then use a StreamWriter
to
write the .reg file, which is just a plain text file in a format that you
can easily see if you export a few keys with regedit.



Preguntas similares