php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36588 COM can't handle out parameter in function call
Submitted: 2006-03-02 11:44 UTC Modified: 2006-03-06 09:21 UTC
From: e dot vandeoudeweetering at marcanti dot esprit-sg dot Assigned:
Status: Not a bug Package: COM related
PHP Version: 5.1.2 OS: Windows 2000 (5.00.2195) SP4
Private report: No CVE-ID: None
 [2006-03-02 11:44 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Description:
------------
When COM is used to retrieve an out parameters value in a function call, the value remains empty.

See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/getstringvalue_method_in_class_stdregprov.asp

Reproduce code:
---------------
$com_reg = new COM("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv");
$value = 'old_value';
$com_reg -> getStringValue('subtree', "key\\subkey", 'entryName', $value);
print $value;

Expected result:
----------------
The value from the registry key 'subtree\key\subkey\entryName' should be printed.

Actual result:
--------------
The value 'old_value' that is declared earlier in the code is printed.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-06 09:21 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Please mark this request as BOGUS!

Wrap the variable into a variant object, then make the function call:

$com_reg = new
COM("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdR
egProv");
$value = new VARIANT();
$com_reg -> getStringValue('subtree', "key\\subkey", 'entryName',
$value);
print $value;

see:
http://bugs.php.net/bug.php?id=16567
http://www.php.net/variant
 [2006-03-06 09:21 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Sorry!

Regards Edwin.
 [2014-04-16 18:29 UTC] mike dot weiss at clear-river dot com
I disagree with the other comment.

According to: http://www.php.net/manual/en/class.com.php

"Starting with PHP 5, PHP will automatically detect methods that accept parameters by reference, and will automatically convert regular PHP variables to a form that can be passed by reference. This means that you can call the method very naturally; you needn't go to any extra effort in your code."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 15:01:28 2024 UTC