note 106337 added to class.com
| From: | rogier at osu1 dot php dot net | Date: | Fri, 28 Oct 2011 17:09:04 +0000 |
| Subject: | note 106337 added to class.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184202@lists.php.net to get a copy of this message | ||
Took me a while to figure this out by trial and error:
If your frustrated when getting a com-exception like "Error [0x80004002] ..." (with a
message nagging you about an unsupported interface), and you're calling a class method through
COM that expects a char as an argument, you should NOT call the method with a single-character
string.
The correct way of calling a method like this is to use a VARIANT with a type of VT_UI1.
COM enabled method definition:
public bool DoSomething(char arg);
<?php
$com = new COM('Some.Class.Name');
// This will fail
$var = 'a';
$com->DoSomething($var);
// This works correctly
$var = new VARIANT(ord('a'), VT_UI1);
$com->DoSomething($var);
?>
I hope this helps some people
----
Server IP: 69.147.83.197
Probable Submitter: 77.171.72.226
----
Manual Page -- http://www.php.net/manual/en/class.com.php
Edit -- https://master.php.net/note/edit/106337
Del: integrated -- https://master.php.net/note/delete/106337/integrated
Del: useless -- https://master.php.net/note/delete/106337/useless
Del: bad code -- https://master.php.net/note/delete/106337/bad+code
Del: spam -- https://master.php.net/note/delete/106337/spam
Del: non-english -- https://master.php.net/note/delete/106337/non-english
Del: in docs -- https://master.php.net/note/delete/106337/in+docs
Del: other reasons-- https://master.php.net/note/delete/106337
Reject -- https://master.php.net/note/reject/106337
Search -- https://master.php.net/manage/user-notes.php