SOL9 Sample: SWbemSecurityCenterQueryApplet
|
1 Screenshot
2 Source code
/*
* SWbemSecurityCenterQueryApplet.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
//SOL9
// 2012/10/12
#include <sol/wmi/SWbemExecQuery.h>
#include <sol/FileWriter.h>
void _tmain(int argc, const TCHAR** argv)
{
ApartmentThreadedModel apartmentThreaded;
try {
Locale locale;
FileWriter writer(L".\\SecurityCenter.xml");
const TCHAR* server = _T(".");
writer.write(L"<?xml version='1.0' ?>\n");
writer.write(L"<WMISecurityCenter>\n");
writer.write(L"<Server>%s</Server>\n", (const wchar_t*)_bstr_t(server));
const TCHAR* spaces[] = {_T("SecurityCenter"), _T("SecurityCenter2")};
const TCHAR* classes[] = {_T("AntiVirusProduct"), _T("AntiSpywareProduct"), _T("FirewallProduct")};
for (int n = 0; n<SizeOf(spaces); n++) {
TCHAR nspace[1024];
_stprintf_s(nspace, SizeOf(nspace), _T("root\\%s"), spaces[n]);
writer.write(L"<%s>\n", (const wchar_t*)_bstr_t(spaces[n]) );
for (int i = 0; i<SizeOf(classes); i++) {
TCHAR query[1024];
_stprintf_s(query, SizeOf(query), _T("select * from %s\n"), classes[i]);
try {
writer.write(L"<%s>\n", (const wchar_t*)_bstr_t(classes[i]) );
SWbemExecQuery query(server, nspace, query, writer);
query.start();
writer.write(L"</%s>\n", (const wchar_t*)_bstr_t(classes[i]) );
} catch (...) {
}
}
writer.write(L"</%s>\n", (const wchar_t*)_bstr_t(spaces[n]) );
}
writer.write(L"</WMISecurityCenter>\n");
writer.close();
} catch (HRESULT hr) {
printf("Exception HRESULT=%0x", hr);
} catch (Exception& ex) {
ex.printf();
} catch (...) {
printf("Unknown IException\n");
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.