Article View: borland.public.cppbuilder.nativeapi
Article #8255Re: How to communicate with Service Application
From: Azrin Aris
Date: Sun, 07 Nov 2004 18:08
Date: Sun, 07 Nov 2004 18:08
75 lines
3096 bytes
3096 bytes
Remy Lebeau (TeamB) wrote:
>
>It is not documented, but TService has a virtual DoCustomControl()
method to
>handle custom messages sent via ControlService().
>
>
>Gambit
>
Remy,
I've tried the ConntrolService Method but my service did not get the
code: here is my code - I use the CustomControl to send the custom
control id to the service. normal Stoping, Pause and Continue works ok
but not the Custom ID:
//For Stopping service
bool __fastcall TAZNTServices::Stop(void)
{
bool retVal = Do_ControlService(SERVICE_CONTROL_STOP);
return retVal;
}
//---------------------------------------------------------------------------
//For sending Custom Control ID
bool __fastcall TAZNTServices::CustomControl(unsigned long aCtrlId)
{
if(aCtrlId>=128 <= 256)
{
bool retVal = Do_ControlService(aCtrlId);
return retVal;
}
return false;
}
//---------------------------------------------------------------------------
//Common Method on sending Control ID to Services
bool __fastcall TAZNTServices::Do_ControlService(unsigned long aCtrlId)
{
bool retVal = false;
if(Open_Service(true))
{
retVal = true;
SERVICE_STATUS SST;
if(!ControlService(schService,aCtrlId,&SST))
{
ShowMyError(GetLastError());
retVal = false;
}
Open_Service(false);
}
return retVal;
}
//---------------------------------------------------------------------------
How do I wrote the Service DoCustomControl implementation? Here is what
I've done:
#define SERVICE_CONTROL_MCAMCONFIG 129
bool __fastcall TMultiCamSvc32::DoCustomControl(unsigned CtrlCode)
{
if(CtrlCode==SERVICE_CONTROL_MCAMCONFIG)
{
ShowMessage("Got it");
}
return true;
}
//---------------------------------------------------------------------------
Technical Details
Message-ID:
<418e6481$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!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>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ec8f0a028cab90e5 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 08 Nov 2004 02:08:03 +0800 From: Azrin Aris <azrin_aris@yahoo.com> User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: How to communicate with Service Application 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> In-Reply-To: <418afe2c$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 203.127.152.28 Message-ID: <418e6481$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1099850881 203.127.152.28 (7 Nov 2004 10:08:01 -0700) Lines: 76 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail