How to open SYSTEM and SAM reg files for reading if they were copied from another PC using C #?

How to read information from them, for example, to get to (file) SOFWARE \ Microsoft \ Windows NT \ CurrentVersion \ NetworkCards?

  • Clarify the question. What happens now when you try to access them: does your program not see them at all or is refused (exception)? I suppose you need to run the program with admin rights. - Alexander Petrov
  • I do not know how to access them. Here let's say in the root of the D drive files are SYSTEM and SOFTWARE. How to get information from them? - Dima
  • If you need to work with the registry, see Registry . - Alexander Petrov
  • Edited the question. It seems you meant it - iluxa1810

2 answers 2

The offline registry file is a text file with the extension * .reg => you can read it as text and parse. There is another HIVE format, which is not a textual representation and is read differently, but is not familiar with it at all.

A regular registry file (not HIVE) has a fairly simple structure, where [] is written the registry branch, and below it is a key-value dictionary. If you believe Google, then it is compatible in * .ini format.

For example, my registry looks like this:

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE] @="" [HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip] "Path"="C:\\Program Files (x86)\\7-Zip\\" "Path64"="C:\\Program Files (x86)\\7-Zip\\" [HKEY_LOCAL_MACHINE\SOFTWARE\ABBYY] [HKEY_LOCAL_MACHINE\SOFTWARE\ABBYY\FineReader] [HKEY_LOCAL_MACHINE\SOFTWARE\ABBYY\FineReader\11.00] [HKEY_LOCAL_MACHINE\SOFTWARE\ABBYY\FineReader\12.00] [HKEY_LOCAL_MACHINE\SOFTWARE\ABBYY\FineReader\12.00\Integration] "SupportedOpenImageFormat"="bmp,dib,rle,dcx,djvu,djv,gif,jb2,jbig2,jp2,j2k,jpf,jpx,jpc,jpg,jpeg,pcx,pdf,png,tif,tiff,xps,wdp,wmp" [HKEY_LOCAL_MACHINE\SOFTWARE\Adobe] [HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Distiller] @="" [HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Distiller\DC] @="" "InstallPath"="C:\\Program Files (x86)\\Adobe\\Acrobat DC\\Acrobat" "RunFromLocalDisk"=dword:00000001 "JobOptions"="Standard" "JobOptionsFolder"="C:\\ProgramData\\Adobe\\Adobe PDF\\Settings\\" "DefaultPDFOutput"="Documents\\*.pdf" 

Here it is actually said that there is nothing ready in .NET and you can try using the INI format parser.

Here is some kind of third - party lib.

     using (RegistryKey registry = Registry.LocalMachine.OpenSubKey(keyPath)) { //читаешь keyPath } 

    which disk is the registry itself is not important.

    • that doesn't work. Maybe I did not say that. In general, I have 4 files representing the registry (SOFTWARE, SYSTEM, SAM, SECURITY) that were copied from another PC. How to read information from them (for example, to get to (file) SOFWARE \ Microsoft \ Windows NT \ CurrentVersion \ NetworkCards)? - Dima
    • one
      @ Dima - edit your question by placing this information in it. - Alexander Petrov
    • There is no possibility of this either in Sharp or WinAPI, as far as I know. If you want to do this, I advise one of the following ways: 1. make backup of the necessary branches and then apply the reg file, process everything and roll back (bad option, if you honestly, you can save the registry). 2. It is banal to parsit the file. In the Internet you can find examples on the Registry Export File (.reg) Parser request. - Andrew