Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);


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.
Posted
Updated 19-Jan-11 1:38am
v2

1 solution

 
Share this answer
 
Comments
Espen Harlinn 19-Jan-11 8:26am    
Can't we assume that m_pStubSink takes care of that - I can see he has not provided the code for his implmentation of IWbemObjectSink, but it seems probable :)
Espen Harlinn 19-Jan-11 8:27am    
5+ Good links though

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900