Unfortunately this group has almost no traffic any more.
(F'up2 microsoft.public.vc.mfc)
microsoft.public.vc.mfc will be finally removed this autumn (maybe it
has already been removed on Microsofts servers), so I would recommend
staying here.
Regarding the original question, MFC does AFAIK not provide any service
specific classes, but it is not so complicated to control services via
the Windows API:
OpenSCManager
OpenService
StartService
ControlService
QueryServiceStatus
CloseServiceHandle
Bye,
Daniel
Bottom line: MFC isn't very useful for system services. You shouldn't use it in the
services, and the APIs, as pointed out below, are sufficiently trivial that you could
build your own class(es) around them.
class Service {
public:
Service(const CString & svcname) { name = svcname; svc = NULL; }
BOOL Open()
{
HANDLE scm = ::OpenSCManager();
if(scm == NULL)
return FALSE;
svc = OpenService(scm, name);
if(svc == NULL)
{
::CloseHandle(scm);
return FALSE;
}
::CloseHandle(scm);
return TRUE;
}
BOOL StartService() {
{
ASSERT(svc != NULL);
if(svc == NULL)
return FALSE;
if(!::StartService(svc))
return FALSE;
return TRUE;
}
protected:
HANDLE svc;
CString name;
};
I did this off the top of my head, without even referring to the documentation, but I
believe it is close enough to the truth to show what you might consider doing. You can
write the other methods As An Exercise For The Reader.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm