Re: "this variant has no properties"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When it comes to doing things with the registry, PHP4 seems to be
better than PHP5:

<?php
$registry = new COM('winmgmts:root/DEFAULT:StdRegProv');
$values = new VARIANT();
echo $registry->getBinaryValue(0x80000002,
'SOFTWARE\\Microsoft\\Cryptography\\RNG', 'Seed', $values);
var_dump($values->value);
?>

That works as expected on PHP4.  On PHP5, it gives yet another "this
variant has no properties" error.


On Wed, Feb 17, 2010 at 5:46 PM, Thomas Anderson <zelnaga@xxxxxxxxx> wrote:
> <?php
> $wscript = new COM('WScript.Shell');
> while (true) {
>    $random = $wscript->RegRead('HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography\\RNG\\Seed');
>    var_dump($random->value);
>    sleep(1);
>    echo "\r\n";
> }
> ?>
>
> That gives me a "this variant has no properties" error.  My question
> is...  how on earth does it not have any properties?  As the following
> VBscript is testament to, it clearly does have properties:
>
> function bin2hex(values)
>        dim result
>        for each value in values
>                temp2 = hex(value)
>                select case len(temp2)
>                        case 0: result = result & "00"
>                        case 1: result = result & "0" & temp2
>                        case 2: result = result & temp2
>                end select
>        next
>        bin2hex3 = result
> end function
>
> Set WshShell = createObject("WScript.Shell")
>
> temp = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\RNG\Seed")
> MsgBox(bin2hex(temp))
>
> Doing vartype on temp reveals that it's an array of variants (VT_ARRAY
> | VT_VARIANT).  Even variant_get_type agrees.  But how do access the
> elements of htat variant array?  Can I?
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux