SOL9 Sample: ServiceControlManager
|
1 Screenshot
2 Source code
/*
* ServiceControlManager.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2010/06/06
#include <sol/service/ServiceControlManager.h>
void _tmain(int argc, TCHAR** argv)
{
if (argc != 2) {
_tprintf(_T("Usage:\n"));
_tprintf(_T("ServiceControlManager \"serviceName\"\n"));
_tprintf(_T("Example. ServiceControlManager LanmanWorkstation\n"));
return;
}
try {
const TCHAR* name = argv[1];
_tprintf(_T("Create an instance of ServiceControlManager\n"));
ServiceControlManager scManager(NULL, NULL, SC_MANAGER_CONNECT);
_tprintf(_T("OK created an instance of ServiceContorlManager\n"));
ServiceController service;
_tprintf(_T("Call ServiceControlManager.openService for %s\n"), name);
scManager.openService(name, SERVICE_QUERY_STATUS, service);
_tprintf(_T("OK opened Service for %s\n"), name);
BOOL running = service.isServiceRunning();
_tprintf(_T("isServiceRunning %d\n"), running);
} catch (HRESULT hr) {
_tprintf(_T("Exception hr=%x\n"), hr);
} catch (...) {
_tprintf(_T("Unknown Exception\n"));
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.