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


PHP COM::ExecNotificationQuery方法代码示例

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


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

示例1: COM

<?php

$strComputer = ".";
$wmi = new COM("winmgmts:\\\\" . $strComputer . "\\root\\cimv2");
$wmiEvent = $wmi->ExecNotificationQuery("SELECT * FROM __InstanceOperationEvent Within 1 Where TargetInstance ISA 'Win32_LogicalDisk'");
$i = 1;
$i++;
while ($i != 0) {
    $usb = $wmiEvent->NextEvent;
    if ($usb->TargetInstance->DriveType == 2) {
        switch ($usb->Path_->Class) {
            case "__InstanceCreationEvent":
                echo "Drive " . $usb->TargetInstance->DeviceId . " has been added.\n";
                break;
            case "__InstanceDeletionEvent":
                echo "Drive " . $usb->TargetInstance->DeviceId . " has been removed.\n";
                break;
        }
    }
}
开发者ID:JhunCabas,项目名称:avarice-nms,代码行数:20,代码来源:monitor-usb-drive.php

示例2: win_time

<?php

//This function converts "20120201211425.631101-300" and rearranges it from
// 2012 02 01 21 14 25 .631101-300
// Year  M  D  H  m  s  micro secs | -300 is offset (EST timezone in this case)
function win_time($timestr)
{
    return substr($timestr, 4, 2) . "/" . substr($timestr, 6, 2) . "/" . substr($timestr, 0, 4) . " " . substr($timestr, 8, 2) . ":" . substr($timestr, 10, 2) . ":" . substr($timestr, 12, 2) . " " . substr($timestr, -4);
    // OUTPUT: 02/01/2012 21:14:25 -300  (M/D/Y H:m:s TZ)
}
$strComputer = ".";
$wmi = new COM("winmgmts:\\\\" . $strComputer . "\\root\\cimv2");
$wmiEvent = $wmi->ExecNotificationQuery("SELECT * FROM __InstanceOperationEvent " . " Within .1 WHERE TargetInstance ISA 'Win32_Process'", "WQL");
$get_user = new Variant("", VT_BSTR);
$get_domain = new Variant("", VT_BSTR);
echo "Monitoring Processes ...\n";
while (true) {
    $evt = $wmiEvent->NextEvent;
    switch ($evt->Path_->Class) {
        case "__InstanceCreationEvent":
            $error = $evt->TargetInstance->GetOwner($get_user);
            if ($error != 0) {
                echo "Could not get Owner Info - Error: " . $error;
            } else {
                $evtCreated = win_time($evt->TargetInstance->CreationDate);
                $evt->TargetInstance->GetOwner($get_user, $get_domain);
                echo "New Process Created  : " . $evtCreated . "\n";
                echo "New Process Name     : " . $evt->TargetInstance->Name . "\n";
                echo "Process Owner        : " . $get_domain . "\\" . $get_user;
                echo "\n" . "New Process Path     : " . $evt->TargetInstance->ExecutablePath . "\n";
                echo "New Process ID       : " . $evt->TargetInstance->ProcessId . "\n";
开发者ID:JhunCabas,项目名称:avarice-nms,代码行数:31,代码来源:process-monitor.php


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