Article View: borland.public.cppbuilder.nativeapi
Article #8250Re: How to communicate with Service Application
From: Remy Lebeau (TeamB)
Date: Fri, 05 Nov 2004 22:41
Date: Fri, 05 Nov 2004 22:41
49 lines
3002 bytes
3002 bytes
"Azrin Aris" <azrin_aris@yahoo.com> wrote in message
news:418bf38c@newsgroups.borland.com...
> how do I set the Description of the service?
TService was written before services supported descriptions, and TService
has not been updated since then, so TService does not natively implement
what you ask for. You will have to assign the description manually. You
should use the ChangeServiceConfig2() API function for that. Note, however,
that ChangeServiceConfig2() does not exist on Windows NT, so if you intend
to run your service on NT then you will have to dynamically load the
function at run-time. For example:
void __fastcall TMyService::ServiceAfterInstall(TService *Sender)
{
typedef BOOL WINAPI LPFN_CSC2A(SC_HANDLE, DWORD, LPVOID);
HINSTANCE hInst = LoadLibrary("advapi32.dll");
if( hInst )
{
LPFN_CSC2A lpChangeServiceConfig2A = (LPFN_CSC2A)
GetProcAddress(hInst, "ChangeServiceConfig2A");
if( lpChangeServiceConfig2A )
{
SC_HANDLE hManager = OpenSCManager(NULL, NULL,
SC_MANAGER_ALL_ACCESS);
if( hManager )
{
SC_HANDLE hService = OpenService(schSCManager,
Sender->Name.c_str(), SERVICE_CHANGE_CONFIG);
if( hService )
{
SERVICE_DESCRIPTION sd = {0};
sd.lpDescription = "My Description Here";
lpChangeServiceConfig2A(hService,
SERVICE_CONFIG_DESCRIPTION, &sd);
CloseServiceHandle(hService);
}
CloseServiceHandle(hManager);
}
}
FreeLibrary(hInst);
}
}
Gambit
Technical Details
Message-ID:
<418c0155@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!transit.nntp.hccnet.nl!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<418581c0$1@newsgroups.borland.com> <4185fb2a$1@newsgroups.borland.com> <41899500$1@newsgroups.borland.com> <4189d65f$1@newsgroups.borland.com> <4189ecdd$1@newsgroups.borland.com> <4189f3b9$1@newsgroups.borland.com> <418ad25b$1@newsgroups.borland.com> <418afe2c$1@newsgroups.borland.com> <418bf38c@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ec8f0a028cab90e5 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <418581c0$1@newsgroups.borland.com> <4185fb2a$1@newsgroups.borland.com> <41899500$1@newsgroups.borland.com> <4189d65f$1@newsgroups.borland.com> <4189ecdd$1@newsgroups.borland.com> <4189f3b9$1@newsgroups.borland.com> <418ad25b$1@newsgroups.borland.com> <418afe2c$1@newsgroups.borland.com> <418bf38c@newsgroups.borland.com> Subject: Re: How to communicate with Service Application Date: Fri, 5 Nov 2004 14:41:23 -0800 Lines: 51 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <418c0155@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1099694421 68.69.17.41 (5 Nov 2004 14:40:21 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!transit.nntp.hccnet.nl!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail