com_print_typeinfo
(PHP 4 >= 4.2.0, PHP 5, PHP 7)
com_print_typeinfo — Print out a PHP class definition for a dispatchable interface
Описание
$comobject
[, string $dispinterface
[, bool $wantsink
= false
]] )The purpose of this function is to help generate a skeleton class for use as an event sink. You may also use it to generate a dump of any COM object, provided that it supports enough of the introspection interfaces, and that you know the name of the interface you want to display.
Список параметров
-
comobject
-
comobject
should be either an instance of a COM object, or be the name of a typelibrary (which will be resolved according to the rules set out in com_load_typelib()). -
dispinterface
-
The name of an IDispatch descendant interface that you want to display.
-
wantsink
-
If set to
TRUE
, the corresponding sink interface will be displayed instead.
Возвращаемые значения
Возвращает TRUE
в случае успешного завершения или FALSE
в случае возникновения ошибки.
Смотрите также
- com_event_sink() - Connect events from a COM object to a PHP object
- com_load_typelib() - Loads a Typelib
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения только для Windows
- COM и .Net (Windows)
- com_create_guid
- com_event_sink
- com_get_active_object
- com_load_typelib
- com_message_pump
- com_print_typeinfo
- variant_abs
- variant_add
- variant_and
- variant_cast
- variant_cat
- variant_cmp
- variant_date_from_timestamp
- variant_date_to_timestamp
- variant_div
- variant_eqv
- variant_fix
- variant_get_type
- variant_idiv
- variant_imp
- variant_int
- variant_mod
- variant_mul
- variant_neg
- variant_not
- variant_or
- variant_pow
- variant_round
- variant_set_type
- variant_set
- variant_sub
- variant_xor
Коментарии
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
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