COM-extension and out-parameters

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I'm writing a small script for accessing the Windows registry using PHP
and the COM-extension. The aim is to get all subkeys of a given registry
key. Since this isn't possible using the "WSHShell" I have to use the
"StdRegProv" class instead.

$oReg = new

$oReg->EnumKey(0x80000002, "SOFTWARE", $subKeys);

The output is NULL. The third parameter of the 'EnumKey' method is a so
called out-parameter, which is something like a reference in PHP. But I
have no idea how to access this parameter. Is it possible to access

As a workaround I now use

$oScriptControl = new COM('MSScriptControl.ScriptControl');
$oScriptControl->Language = 'vbscript';

Function GetRegistryKeys(sKey)
     const HKEY_LOCAL_MACHINE = &H80000002

     Set oReg =
     oReg.EnumKey HKEY_LOCAL_MACHINE, sKey, aSubKeys

     GetRegistryKeys = aSubKeys
End Function

function GetRegistryKeys($key) {
     global $oScriptControl;
     return $oScriptControl->Run("GetRegistryKeys", $key);

This works, but this is pain in the ass.

Any suggestions?


Site Timeline