Registry Virtualization Example with BoxedApp SDK

This example demonstrates how to create a virtual registry key using BoxedApp SDK. Virtual registry entries behave like real ones for the application, but they are not written to the actual Windows Registry.

A virtual registry key exists only inside the virtualization layer. It is visible to the process that created it and to child processes that inherit the same virtual environment. From the OS perspective, no real keys or values are modified.

This technique is useful when you need to emulate COM or ActiveX registration without administrative privileges, or when you want to protect registry-dependent configuration from being exposed or altered in the system. Typical scenarios include registering ActiveX controls, testing applications without modifying user or system hives, and isolating per-process configuration.

C++ Sample

// Create hKey_Classes for registry reflection compatibility
HKEY hKey_Classes;
RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), &hKey_Classes);
 
HKEY hVirtualKey;
DWORD dwDisposition;
 
LONG lResult = BoxedAppSDK_CreateVirtualRegKey(
  hKey_Classes,
  _T("TypeLib\\{D27CDB6B-AE6D-11CF-96B8-444553540000}"),
  0,
  NULL,
  REG_OPTION_NON_VOLATILE,
  KEY_ALL_ACCESS,
  NULL,
  &hVirtualKey,
  &dwDisposition
);
 
// Example: register version 1.0
HKEY hVirtualKey_10;
lResult = BoxedAppSDK_CreateVirtualRegKey(
  hKey_Classes,
  _T("TypeLib\\{D27CDB6B-AE6D-11CF-96B8-444553540000}\\1.0"),
  0,
  NULL,
  REG_OPTION_NON_VOLATILE,
  KEY_ALL_ACCESS,
  NULL,
  &hVirtualKey_10,
  &dwDisposition
);
 
// Set value under virtual key
TCHAR buf[1024] = _T("Shockwave Flash");
RegSetValueEx(
  hVirtualKey_10,
  _T(""),
  0,
  REG_SZ,
  (const BYTE*)buf,
  (lstrlen(buf) + 1) * sizeof(TCHAR)
);