put_EnableVirtualRegistry

Description

Specifies whether the packed executable uses the virtual registry layer, which intercepts all registry operations before they reach the real Windows registry.

When this option is enabled, the packed application interacts with the virtual registry first.
If a requested key or value exists in the virtual registry, it is read from there — even if it does not exist in the actual system registry.
If the requested key or value is missing in the virtual registry, the request is then forwarded to the real Windows registry.

Thus, the packed executable transparently combines data from both the virtual and real registries.

If the option "all changes are virtual" is also enabled, all registry modifications (creating, editing, or deleting keys and values) are written exclusively to the virtual registry, leaving the real registry unchanged.

Syntax

HRESULT put_EnableVirtualRegistry([in] VARIANT_BOOL bValue);

Parameters

bValue
Type: VARIANT_BOOL
[in] Pass VARIANT_TRUE to enable the virtual registry layer or VARIANT_FALSE to disable it.

Return Value

Returns an HRESULT.

  • S_OK — the setting was successfully applied.
  • E_FAIL or another COM error code — the operation failed.

Example

CComPtr<IBxProject> project;
if (SUCCEEDED(BxPackerApi_CreateProject(&project))) {
    // Enable virtual registry support
    project->put_EnableVirtualRegistry(VARIANT_TRUE);
 
    // Optionally make all registry changes virtual as well
    project->put_AllChangesAreVirtual(VARIANT_TRUE);
 
    // Continue configuring the project...
}

Remarks

  • When enabled, the packed executable queries the virtual registry first before accessing the real one.
  • This approach lets applications operate normally even without administrative privileges.
  • It also prevents unwanted system modifications while maintaining compatibility with the Windows API.
  • If "all changes are virtual" is not set, applications can still modify the real registry, but reads and lookups always check the virtual layer first.
  • This makes it possible to emulate registry data for testing or build fully portable applications.
  • The current state can be checked using get_EnableVirtualRegistry.

See Also