WMI指示 [英] WMI Indicate

查看:73
本文介绍了WMI指示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个不是我创建的项目,并且我对WMI也不满意:(.我将用示例解释我的要求:
假设我打开了Notepad.exe的第一个实例,然后保存了该Notepad.exe的时间,而我的最后一个Notepad.exe实例被保存在了我的应用程序中.

我要做的是:

I am working on one project that was not created by me and I am not comfortable with WMI also :(. I will explain my requirement with example:
Suppose I open first instance of Notepad.exe then the time of that Notepad.exe is saved and whatever be my last instance of Notepad.exe that time is saved in my application.

What I do is:

hRes = m_pWbemServices->ExecNotificationQueryAsync(
        _bstr_t("WQL"),
        _bstr_t("SELECT * "
        "FROM __InstanceDeletionEvent WITHIN 1 "
        "WHERE TargetInstance ISA ''Win32_Process''"),
        WBEM_FLAG_SEND_STATUS,
        NULL,
        m_pStubSink);
    hRes = m_pWbemServices->ExecNotificationQueryAsync(
        _bstr_t("WQL"),
        _bstr_t("SELECT * "
        "FROM __InstanceCreationEvent WITHIN 1 "
        "WHERE TargetInstance ISA ''Win32_Process''"),
        WBEM_FLAG_SEND_STATUS,
        NULL,
        m_pStubSink);



我编写查询以创建和删除进程.当任何进程打开或关闭时,都会调用Indicate函数,但是我怎么知道该进程是启动还是退出?

还有另一种方法吗?

如果是这样,请解释.



I write query for process creation and deletion. When any process is open or closed then at Indicate function get called but how do I know that this process is started or exited?

Is there another way to do this?

If so please explain.

推荐答案

您必须在事件代码中添加事件处理程序.

http://msdn.microsoft.com/en-us/library/aa392106(VS .85).aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/aa393017 (v = VS.85).aspx [
You have to add event handlers in your code for the events.

http://msdn.microsoft.com/en-us/library/aa392106(VS.85).aspx[^]

http://msdn.microsoft.com/en-us/library/aa393017(v=VS.85).aspx[^]


这篇关于WMI指示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆