当前位置: 首页>>代码示例>>PHP>>正文


PHP COM::EnumKey方法代码示例

本文整理汇总了PHP中COM::EnumKey方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::EnumKey方法的具体用法?PHP COM::EnumKey怎么用?PHP COM::EnumKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COM的用法示例。


在下文中一共展示了COM::EnumKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Win32RegistryIterator

function Win32RegistryIterator(COM $o_Win32Registry, $i_HiveKey, $s_RootKey)
{
    static $i_Depth = -1;
    static $a_RegTypes = array(1 => 'REG_SZ (1)', 2 => 'REG_EXPAND_SZ (2)', 3 => 'REG_BINARY (3)', 4 => 'REG_DWORD (4)', 7 => 'REG_MULTI_SZ (7)', 10 => 'REG_RESOURCE_REQUIREMENT_LIST (10)');
    $a_Keys = new VARIANT();
    $a_Names = new VARIANT();
    $a_Types = new VARIANT();
    $i_EnumKeyState = $o_Win32Registry->EnumKey($i_HiveKey, $s_RootKey, $a_Keys);
    $i_EnumValuesState = $o_Win32Registry->EnumValues($i_HiveKey, $s_RootKey, $a_Names, $a_Types);
    if (VT_NULL !== variant_get_type($a_Keys)) {
        foreach ($a_Keys as $i_Key => $s_Key) {
            echo '[', $s_Key, ']', PHP_EOL;
            Win32RegistryIterator($o_Win32Registry, $i_HiveKey, $s_RootKey . '\\' . $s_Key);
        }
    }
    if (VT_NULL !== variant_get_type($a_Names)) {
        $a_ExtractedTypes = array();
        foreach ($a_Types as $i_Type) {
            $a_ExtractedTypes[] = $i_Type;
        }
        foreach ($a_Names as $i_Name => $s_Name) {
            $m_RegValue = new VARIANT();
            echo $i_Name, ' => ', '' === $s_Name ? '(Default)' : $s_Name, ' of type ', $a_RegTypes[$a_ExtractedTypes[$i_Name]], ' with a value of ';
            switch ($a_ExtractedTypes[$i_Name]) {
                case 1:
                    // REG_SZ
                    $o_Win32Registry->GetStringValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    echo '"', $m_RegValue, '"';
                    break;
                case 2:
                    // REG_EXPAND_SZ
                    $o_Win32Registry->GetExpandedStringValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    echo '"', $m_RegValue, '"';
                    break;
                case 3:
                    // REG_BINARY
                // REG_BINARY
                case 10:
                    // REG_RESOURCE_REQUIREMENT_LIST
                    $o_Win32Registry->GetBinaryValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    if (VT_NULL !== variant_get_type($m_RegValue)) {
                        foreach ($m_RegValue as $i_RegValue) {
                            echo str_pad(dechex($i_RegValue), 2, '0', STR_PAD_LEFT), ' ';
                        }
                    }
                    break;
                case 4:
                    // REG_DWORD
                    $o_Win32Registry->GetDWORDValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    echo '0x', str_pad(dechex($m_RegValue), 8, '0', STR_PAD_LEFT), ' (', $m_RegValue, ')';
                    break;
                case 7:
                    // REG_MUTLI_SZ
                    $o_Win32Registry->GetMultiStringValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    if (VT_NULL !== variant_get_type($m_RegValue)) {
                        try {
                            foreach ($m_RegValue as $s_RegValue) {
                                echo PHP_EOL, $s_RegValue;
                            }
                        } catch (com_exception $e) {
                            // As yet, I cannot determine if the $m_RegValue is empty for a REG_MULTI_SZ,
                            // so catch the exception and test that instead.
                            if (-2147352565 !== $e->getCode()) {
                                throw $e;
                            }
                        }
                    }
                    break;
            }
            echo PHP_EOL;
        }
    }
}
开发者ID:JhunCabas,项目名称:avarice-nms,代码行数:73,代码来源:reg.php

示例2: Win32RegistryIterator

function Win32RegistryIterator(COM $o_Win32Registry, $i_HiveKey, $s_RootKey)
{
    static $i_Depth = -1;
    static $a_RegTypes = array(1 => 'REG_SZ (1)', 2 => 'REG_EXPAND_SZ (2)', 3 => 'REG_BINARY (3)', 4 => 'REG_DWORD (4)', 7 => 'REG_MULTI_SZ (7)', 10 => 'REG_RESOURCE_REQUIREMENT_LIST (10)');
    $return = array();
    $a_Keys = new VARIANT();
    $a_Names = new VARIANT();
    $a_Types = new VARIANT();
    $i_EnumKeyState = $o_Win32Registry->EnumKey($i_HiveKey, $s_RootKey, $a_Keys);
    $i_EnumValuesState = $o_Win32Registry->EnumValues($i_HiveKey, $s_RootKey, $a_Names, $a_Types);
    if (VT_NULL !== variant_get_type($a_Keys)) {
        foreach ($a_Keys as $i_Key => $s_Key) {
            $return[$s_Key] = Win32RegistryIterator($o_Win32Registry, $i_HiveKey, $s_RootKey . '\\' . $s_Key);
        }
    }
    if (VT_NULL !== variant_get_type($a_Names)) {
        $a_ExtractedTypes = array();
        foreach ($a_Types as $i_Type) {
            $a_ExtractedTypes[] = $i_Type;
        }
        foreach ($a_Names as $i_Name => $s_Name) {
            $m_RegValue = new VARIANT();
            switch ($a_ExtractedTypes[$i_Name]) {
                case 1:
                    // REG_SZ
                    $o_Win32Registry->GetStringValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    break;
                case 2:
                    // REG_EXPAND_SZ
                    $o_Win32Registry->GetExpandedStringValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    break;
                case 3:
                    // REG_BINARY
                // REG_BINARY
                case 10:
                    // REG_RESOURCE_REQUIREMENT_LIST
                    $o_Win32Registry->GetBinaryValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    if (VT_NULL !== variant_get_type($m_RegValue)) {
                        $tempval = "";
                        foreach ($m_RegValue as $i_RegValue) {
                            $tempval .= str_pad(dechex($i_RegValue), 2, '0', STR_PAD_LEFT) . ' ';
                        }
                        $m_RegValue = $tempval;
                    }
                    break;
                case 4:
                    // REG_DWORD
                    $o_Win32Registry->GetDWORDValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    $m_RegValue = '0x' . str_pad(dechex($m_RegValue), 8, '0', STR_PAD_LEFT) . ' (' . $m_RegValue . ')';
                    break;
                case 7:
                    // REG_MUTLI_SZ
                    $o_Win32Registry->GetMultiStringValue($i_HiveKey, $s_RootKey, $s_Name, $m_RegValue);
                    if (VT_NULL !== variant_get_type($m_RegValue)) {
                        try {
                            $tempval = "";
                            foreach ($m_RegValue as $s_RegValue) {
                                $tempval .= $s_RegValue;
                            }
                            $m_RegValue = $tempval;
                        } catch (com_exception $e) {
                            // As yet, I cannot determine if the $m_RegValue is empty for a REG_MULTI_SZ,
                            // so catch the exception and test that instead.
                            if (-2147352565 !== $e->getCode()) {
                                throw $e;
                            }
                        }
                    }
                    break;
            }
            if ('' === $s_Name) {
                $key = '(Default)';
            } else {
                $key = $s_Name;
            }
            $return[$key] = array('type' => $a_RegTypes[$a_ExtractedTypes[$i_Name]], 'value' => (string) $m_RegValue);
        }
    }
    return $return;
}
开发者ID:JhunCabas,项目名称:avarice-nms,代码行数:80,代码来源:registry.php


注:本文中的COM::EnumKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。