http://blog.csdn.net/jpexe/article/details/4296955
// ---------------------------------------------------------------------------
// 设置服务的描述
void TService1::SetDescription(WideString Desc)
{
SC_HANDLE hSCM;
SC_HANDLE hService;
SERVICE_DESCRIPTION sd;
hSCM = OpenSCManager(
NULL,
NULL,
SC_MANAGER_ALL_ACCESS);
if (hSCM == 0)
{
return;
}
hService = OpenService(
hSCM,
this->DisplayName.c_str(),
SERVICE_CHANGE_CONFIG);
if (hService == 0)
{
return;
}
sd.lpDescription = Desc.c_bstr();
ChangeServiceConfig2(
hService,
SERVICE_CONFIG_DESCRIPTION,
& sd);
CloseServiceHandle(hService);
CloseServiceHandle(hSCM);
}
//---------------------------------------------------------------------------
void __fastcall TService1::ServiceAfterInstall(TService *Sender)
{
// 安装结束以后, 设置服务的描述
this->SetDescription
(L" 我的描述 描述 喵");
}
//---------------------------------------------------------------------------