COM and reference or smart pointers ....
| From: | Ruben Goethals | Date: | Mon, 31 Mar 2003 16:15:18 +0000 |
| Subject: | COM and reference or smart pointers .... | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-19220@lists.php.net to get a copy of this message | ||
Hi, I am writing a php application to use a com object that is defined in my
OS, but I have difficulties getting a (smart)pointer from another
com-object.
Here is the code (untill the error):
******************************************************************
$ConnectionObj = new COM("Falcon.ConnectionObject") or die("Unable to
instanciate ConnectionObject"); //First COM-object !!!!
print "Loaded ConnectionObject\n";
$GroupDataObj = new COM("Falcon.GroupData") or die("Unable to instanciate
GroupDataObject"); //Second COM-object!!!
print "Loaded GroupDataObject\n";
$devOpenErr = $ConnectionObj->Open2("FalconEdi.Pei16Edi.1","COM1");//);
//Get a connection to some thing :-)
$result = $GroupDataObj->Connection($ConnectionObj); //Here is the error
******************************************************************
At this last line I get the error Invoke() failed:exception occured. I think
this is because I don't know how to get a smartpointer to that
ConnectionObject. Because a parameter in the GroupDataObj must be a pointer
to the first COM-object and this is done throught this function
(GroupDataObj->Connection) which takes a pointer to that first com-object.
The function GroupDataObj->Connection is defined as follows:
******************************************************************
HRESULT IGroupDataTransfer::Connection ( [in] IConnection * newVal )
******************************************************************
with "IConnection" the Interface "Falcon.ConnectionObject" like in my php
code above.
In C++, I would have done that last line as follows:
******************************************************************
HRESULT hr = GroupdataObj->Connection (IConnectionPtr(IConnectionObj));
******************************************************************
But in C++ the headers are used and this is what I found for the definition
of IConnectionPtr:
******************************************************************
#if defined(__cplusplus) && defined(_MSC_VER) &&
defined(_COM_SMARTPTR_TYPEDEF)
_COM_SMARTPTR_TYPEDEF(IConnection, __uuidof(IConnection));
******************************************************************
Anybody knows ho to do that in PHP ?
Are these variables I created abov, "$ConnectionObj" and
"$GroupDataObj" pointers or php-com-structures or both ? If not the first
how can you get a pointer to it then ?
Thanks