Article View: borland.public.cppbuilder.nativeapi
Article #10108Re: Hybrid (Service + App)
From: Remy Lebeau (TeamB)
Date: Fri, 14 May 2004 20:21
Date: Fri, 14 May 2004 20:21
55 lines
2666 bytes
2666 bytes
"Frank Gruber" <HVFDMIPUMFPS@spammotel.com> wrote in message
news:40a510da$1@newsgroups.borland.com...
> I think it doesn't matter.
Well, it does, because the coding is different depending on which approach
you take.
> If there is a VCL based solution available which saves
> some work - why not.
What I do in that situation is to modify the service's WinMain() function
directly. When I want to run as a service, I let the default service code
execute. When I want to run as a normal application, I simply bypass the
default code and run my normal code instead. For example:
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
if( should run as service )
{
Svcmgr::Application->Initialize();
Svcmgr::Application->CreateForm(__classid(TMyService),
&MyService);
Svcmgr::Application->Run();
}
else
{
Forms::Application->Initialize();
Forms::Application->CreateForm(__classid(TMyForm), &MyForm);
Forms::Application->Run();
}
}
catch (Exception &exception)
{
Sysutils::ShowException(&exception, System::ExceptAddr());
}
return 0;
}
The only downside to this approach is that the IDE auto-manages the contents
of WinMain() and thus overwrites the code periodically. Its really
annoying!
> AFAIK TThreads create one for synchronisation
> with the main thread.
That is not true, TThread does not have a window handle at all. It merely
posts a message to the TApplication's Handle instead, and then
Gambit
Technical Details
Message-ID:
<40a52b88$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40a4b84e@newsgroups.borland.com> <40a50242$1@newsgroups.borland.com> <40a510da$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,f39ab9099040c7a4 X-Google-Attributes: gid10cc67,public From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40a4b84e@newsgroups.borland.com> <40a50242$1@newsgroups.borland.com> <40a510da$1@newsgroups.borland.com> Subject: Re: Hybrid (Service + App) Date: Fri, 14 May 2004 13:21:35 -0700 Lines: 57 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <40a52b88$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1084566408 67.22.138.253 (14 May 2004 13:26:48 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail