|
użytkowników online: 63
|
OPINIE UŻYTKOWNIKÓW
|
Przyznam, że jestem pod sporym wrażeniem. Od wielu lat zajmuje się grafiką przeznaczoną do druku ze szczególnym uwzględnieniem opakowań. Z radością stwierdzam, iż twórca serwisu jest moim ulubionym typem potencjalnego współpracownika (choć branża troszeczkę inna) tzn. pada pytanie i błyskawicznie pada konkretna odpowiedź bez względu na stopień skomplikowania pytania. Gorąco polecam współpracę, gdyż macie pewność że nie zostaniecie potraktowani sloganami typu "oczywiście", "nie ma sprawy" tylko otrzymacie konkretną pomoc. Tak trzymać! Na pewno jeszcze nie raz skorzystam
Paweł
Studio Gama
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
Rozdział 72. PHP and COM
PHP can be used to access COM and DCOM objects on Win32 platforms.
- 1.
I have built a DLL to calculate something. Is there any way to run this DLL under PHP ?
- 2.
What does 'Unsupported variant type: xxxx (0xxxxx)' mean ?
- 3.
Is it possible manipulate visual objects in PHP ?
- 4.
Can I store a COM object in a session ?
- 5.
How can I trap COM errors ?
- 6.
Can I generate DLL files from PHP scripts like i can in Perl ?
- 7.
What does 'Unable to obtain IDispatch interface for CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}' mean ?
- 8.
How can I run COM object from remote server ?
- 9.
I get 'DCOM is disabled in C:\path...\scriptname.php on line 6', what can I do ?
- 10.
Is it possible to load/manipulate an ActiveX object in a page with PHP ?
- 11.
Is it possible to get a running instance of a component ?
- 12.
Is there a way to handle an event sent from COM object ?
- 13.
I'm having problems when trying to invoke a method of a COM object
which exposes more than one interface. What can I do ?
- 14.
So PHP works with COM, how about COM+ ?
- 15.
If PHP can manipulate COM objects, can we imagine to use
MTS to manage components resources, in conjunction with PHP ?
1.
I have built a DLL to calculate something. Is there any way to run this DLL under PHP ?
If this is a simple DLL there is no way yet to run it from PHP. If the DLL contains a COM
server you may be able to access it if it implements the IDispatch interface.
2.
What does 'Unsupported variant type: xxxx (0xxxxx)' mean ?
There are dozens of VARIANT types and combinations of them. Most of them are already supported but
a few still have to be implemented.
Arrays are not completely supported. Only single dimensional indexed
only arrays can be passed between PHP and COM.
If you find other types that aren't supported, please report them as a bug (if not already reported)
and provide as much information as available.
3.
Is it possible manipulate visual objects in PHP ?
Generally it is, but as PHP is mostly used as a web scripting language it runs in the web servers context, thus
visual objects will never appear on the servers desktop.
If you use PHP for application scripting e.g. in conjunction with PHP-GTK there is no limitation in accessing and
manipulating visual objects through COM.
4.
Can I store a COM object in a session ?
No, you can't. COM instances are treated as resources and therefore they are only available in a single script's context.
5.
How can I trap COM errors ?
In PHP 5, the COM extension throws com_exception
exceptions, which you can catch and then inspect the code
member to determine what to do next.
In PHP 4 it's not possible to trap COM errors beside the ways provided by PHP itself (@, track_errors, ..).
6.
Can I generate DLL files from PHP scripts like i can in Perl ?
No, unfortunately there is no such tool available for PHP.
7.
What does 'Unable to obtain IDispatch interface for CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}' mean ?
This error can have multiple reasons:
8.
How can I run COM object from remote server ?
Exactly like you run local objects. You only have to pass the IP of the remote machine as second parameter to
the COM constructor.
Make sure that you have set
com.allow_dcom
=TRUE in your php.ini.
9.
I get 'DCOM is disabled in C:\path...\scriptname.php on line 6', what can I do ?
10.
Is it possible to load/manipulate an ActiveX object in a page with PHP ?
This has nothing to do with PHP. ActiveX objects are loaded on client side if they are requested
by the HTML document. There is no relation to the PHP script and therefore there is no direct
server side interaction possible.
11.
Is it possible to get a running instance of a component ?
This is possible with the help of monikers. If you want to get multiple references to the same word instance
you can create that instance like shown:
|
<?php
$word = new COM("C:\docs\word.doc");
?>
|
This will create a new instance if there is no running instance available or it will return a handle to the
running instance, if available.
12.
Is there a way to handle an event sent from COM object ?
13.
I'm having problems when trying to invoke a method of a COM object
which exposes more than one interface. What can I do ?
The answer is as simple as unsatisfying. I don't know exactly but i think you can do nothing.
If someone has specific information about this, please let me know :)
14.
So PHP works with COM, how about COM+ ?
COM+ extends COM by a framework for managing components through MTS and MSMQ but there is nothing special that
PHP has to support to use such components.
15.
If PHP can manipulate COM objects, can we imagine to use
MTS to manage components resources, in conjunction with PHP ?
PHP itself doesn't handle transactions yet. Thus if an error
occurs no rollback is initiated. If you use components that
support transactions you will have to implement the
transaction management yourself.
User Contributed Notes17-Jul-2005 01:56
Re: The Windows English CHM Sample with MS Word Automation.
I see that $Word->Release() is called after $Word->Quit().
This seems to be erroneous. Actually, $Word->Release() should not have to be called if proper COM garbage collection is taking place. Release() is a C++ construction not used in either Visual Basic or VBScript or even MS-JScript. Just to be sure, however, I ran the sample through php.exe (5.04 CLI on Windows XP SP1 with Office 2003) and got a RPC failed error on the line containing $Word->Release(). The rest of the sample works fine, and the results are as expected. So, I propose 2 scenarios:
1.There is a problem with the documentation (more likely).
2.There is a problem with PHP504 itself, as this problem is reproduced with any COM Automation call, not just Word.
jeanpierre dot vincent at gmail dot com
03-Feb-2005 03:56
Be careful with function com_event_sink(), it doesn't totally work : when catching events, all parameters given to your callback function have the same value as the last one => see bug http://bugs.php.net/bug.php?id=31040
junk.ghost@virgin dOtt net
05-Oct-2004 06:27
It may be obvious to everyone else but...
If you want to write your own COM DLL in MSVC++6 and you want to pass it a string, you need the following in your .idl file:
HRESULT function_name([in] BSTR parameter_name,
[retval, out] BSTR * retval);
retval is the result of your function as a string to be passed back.
BSTR is an unsigned short *, so if you want to use your string with STL string etc. you may need to convert parameters to and from char *.
The burden of my message is that from PHP
$comThing = new COM("comThing.comThing");
print $comThing->function_name("Jeremy");
Jeremy will be marshalled as wide chars, which match BSTR.
ALAN at DONTSPAMMEE;HOGAR dot COM
17-Aug-2002 06:39
ONE SAMPLE USING MS-XML3 PARSER ON WINDOWS
<?
$xml= new COM("Microsoft.XMLDOM");
$xml->async=false;
$xml->load("STYLE.xml");
$xsl = new COM("Microsoft.XMLDOM");
$xsl->async=false;
$xsl->load("STYLE.xsl");
$response=$xml->transformNode($xsl);
print $response;
?>
|