SOL9 Sample: SWbemServiceModificationNotificationQueryApplet
|
1 Screenshot
2 Source code
/*
* SWbemServiceModificationNotificationQueryApplet.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
//SOL9
// 2009/12/13
#include <sol/wmi/SWbemNotificationQueryApplet.h>
namespace SOL {
/**
* Thread of SWbemServices::ExeNotificationQuery to watch __InstantModificastionEvent for Win32_Service
*/
class SWbemServiceModificationNotificationQueryApplet: public SWbemNotificationQueryApplet {
public:
/**
* Constructor
*/
SWbemServiceModificationNotificationQueryApplet()
{
}
public:
/**
* Thread procedure to watch an instance modification event of Win32_Service.
*/
virtual void display(SWbemEventSource& eventSource)
{
bool looping = true;
while (looping) {
try {
SWbemQueryProperties& properties = getQueryProperties();
int nextEventInterval = properties.getNextEvent();
SWbemObject object = eventSource.nextEvent(nextEventInterval);
_bstr_t text = object.getObjectText(0);
printf("\n\nService %S\n", (const wchar_t*)text);
SWbemObjectPath path = object.getPath();
_bstr_t strClass = path.getClass();
printf("Notified SWbemObject Class=%S\n", (const wchar_t*)strClass);
} catch (...) {
}
}
}
};
}
void _tmain(int argc, const TCHAR ** argv)
{
try {
Locale locale;
SWbemServiceModificationNotificationQueryApplet applet;
applet.start();
applet.wait();
} catch (...) {
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.