In my particular version of PHP, the second and third arguments are not, in fact, optional.
Passing in '' for both, however, yielded a bucketful of information.
YMMV
com_print_typeinfo
(PHP 4 >= 4.2.0, PHP 5)
com_print_typeinfo — Imprime una definición de clase de PHP para una interfaz despachable
Descripción
$comobject
[, string $dispinterface
[, bool $wantsink = false
]] )El propósito de esta función es ayudar a generar una clase esqueleto para usarla como absorción de eventos. También se puede usar para generar una copia de cualquier objeto COM, siempre que soporte lo suficiente las interfaces de introspección, y que usted sepa el nombre de la interfaz que quiere mostrar.
Parámetros
-
comobject -
comobjectdebería ser una instancia de un objeto COM, o el nombre de una biblioteca de tipos (que será resuelta según el conjunto de reglas de com_load_typelib()). -
dispinterface -
El nombre de una interfaz descendiente de IDispatch que se quiere mostrar.
-
wantsink -
Si se establece a
TRUE, en su lugar se mostrará la interfaz de absorción.
Valores devueltos
Devuelve TRUE en caso de éxito o FALSE en caso de error.
Ver también
- com_event_sink() - Conectar eventos de un objeto COM a un objeto PHP
- com_load_typelib() - Carga una biblioteca de tipos
com_print_typeinfo is really useful if you're trying to figure out what properties and methods you have access to. For example, I might do:
<?php
$oExplorer = new COM("Shell.Application");
com_print_typeinfo($oExplorer);
?>
The first line shows me the class of the object (what VBScript calls 'typename'), in my case IShellDispatch4. It's frequently the case that if you plunk that in as the second argument to com_print_typeinfo, you get way more methods/properties coming back. Thus:
<?php
$oExplorer = new COM("Shell.Application");
com_print_typeinfo($oExplorer, "IShellDispatch4");
?>
Furthermore, you might get additional functions listed if you try lower number suffixes (or not). At any rate, it would be useful for PHP to have a typename function like VBScript does. For example, if you iterate through the Windows of $oExplorer you get both IE and Explorer windows and typename is the easy way to differentiate between them. Here's what I'm using:
<?php
function typeName($objCOM) {
if (empty($objCOM)) return "no COM object";
if (gettype($objCOM)!="object") return "not a COM object";
ob_start();
com_print_typeinfo($objCOM);
$typeInfo = ob_get_contents();
ob_end_clean();
$pattern = "/^\\s*class (.*) \\{/";
if (!($matchCnt = preg_match($pattern, $typeInfo, $aMatch))) return "Not found";
return $aMatch[1];
}
?>
Csaba Gabor from Vienna
