Article View: borland.public.csharpbuilder.language.csharp
Article #681Re: writng Win32service in BorlandC#Builder How do I do it?
From: Marc Rohloff TeamB
Date: Wed, 27 Oct 2004 00:03
Date: Wed, 27 Oct 2004 00:03
69 lines
3971 bytes
3971 bytes
On Mon, 25 Oct 2004 16:03:29 +0200, J.A Smit wrote:
> Step 1)
> How do I create an empty project?
a) Create a console app and in the project options set the type to
'Windows Executable'
-or-
b) Create a Winforms app and remove the default form and code inside
main as well as references to System.Windows.Forms.
> The reference is something like: "using System.ServiceProcess; " at the top
> of the file, right?
No that is a namespace import.
No. In the project manager tree view right click references and choose
add reference and then choose System.ServiceProcess.
> Step3)Shouldn't this be part of the class in Step2 ?? I mean " Step2{
> Step3{ }} "
Yes this code is the constructor for your service.
> Step4) This is just the main() part of the program, right?
Yes. It probably already existed.
> Step 7)
> Here they mean the two other classes Windows Service Installer and
> WindowsServiceProcessInstaller ,right?
No not really. You would normally create a single subclass of
System.Configuration.Install.Installer and apply the
RunInstaller(true) attribute to it.In the constructor it should create
an instance of the predefined ServicePorcessInstaller, set it's
properties (Account, Password, Username) and call this.Installers.Add
with it. You also create an instance of
System.ServiceProcess.ServiceInstaller, set its
properties(ServiceName, DisplayName, StartType, ServicesDependedOn)
and again add it using Installers.Add.
> Judging by your previous mail I can put these class defs in the same .cs
> file, right ?
Yes you can but I would use one file per class.
> Step 8)
> Compile , right?
> Step 9)
> This one I don't get at all. "Setup project"?
Generally your setup would call installutil passing your service's
executable as a parameter. InstallUtil will then search your
executable for the installer subclass and execute it appropriately.
(If you run your code normally it will run the service)
I would guess that .net ready setup creator will have an action for
this.
> Step 10)
> This is the installing as a service with the InstallUtil.exe , right?
Run your setup or call InstallUtil directly.
> So as I see it know I have three .sc files MyService , MyServiceInstall and
> MyServiceProcessInstall I compile / build these into a MyService.exe witch I
> then install as a service with InstallUtil.exe.
No you shouldn't have one for MySericeProcessInstall. You should have
the AssemblyInfo file and you can choose wether you want to write main
in it's own class/file or include it as part of your service class (if
you only have one service)
--
Marc Rohloff [TeamB]
marc rohloff at myrealbox dot com
Technical Details
Message-ID:
<vxqjwldnmogt$.dlg@marcrohloff.40tude.net>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!195.5.65.34.MISMATCH!caladan.arrakis.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<417bf043$1@newsgroups.borland.com> <hyra00h6xyiu$.dlg@marcrohloff.40tude.net> <417ca911$1@newsgroups.borland.com> <l20k7t6gap29.dlg@marcrohloff.40tude.net> <417d07ce$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,a97d3f9f5adb9274 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Marc Rohloff [TeamB]" <"on request"> Subject: Re: writng Win32service in BorlandC#Builder How do I do it? Newsgroups: borland.public.csharpbuilder.language.csharp User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit References: <417bf043$1@newsgroups.borland.com> <hyra00h6xyiu$.dlg@marcrohloff.40tude.net> <417ca911$1@newsgroups.borland.com> <l20k7t6gap29.dlg@marcrohloff.40tude.net> <417d07ce$1@newsgroups.borland.com> Date: Tue, 26 Oct 2004 20:03:48 -0400 Message-ID: <vxqjwldnmogt$.dlg@marcrohloff.40tude.net> NNTP-Posting-Host: 4.225.101.156 X-Trace: newsgroups.borland.com 1098835448 4.225.101.156 (26 Oct 2004 17:04:08 -0700) Lines: 69 X-Authenticated-User: mrohloff Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!195.5.65.34.MISMATCH!caladan.arrakis.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail