當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。