The code snippet exports registry key (with values and subkeys) into .reg file format stream. The stream can be memory stream or any other IStream compatible implemetnation. See also: How To Add, Modify, or Delete Registry Subkeys and Values by Using a Registration Entries (.reg) File Visual C++.NET 2003 project: Download