🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16204

Re: Troubles with services

#16204
From: Remy Lebeau (TeamB)
Date: Mon, 26 May 2003 22:08
62 lines
3297 bytes
"Stefano Bonifazi" <stefboombastic@libero.it> wrote in message
news:3ed1e176@newsgroups.borland.com...

> First of all I'd need to get the .exe name of my service
> within the service itself ... of course I tried with the
> Application->ExeName, but the compiler complains
> about an ambiguity between 'Application' and
> 'Svcmgr::Application' , if then I put the scope resolution:
> Svcmgr::Application->EXEName it screams as
> 'ExeName is not a member of 'TServiceApplication'

You need to use the "Forms" namespace, not the "Svcmgr" namespace:

    Forms::Application->ExeName

The alternative is to not use TApplication::ExeName at all, but use
ParamStr(0) instead (which is what TApplication::ExeName calls insternally
anyway).

>  Then from within another application I would like to
> install my service (and then starting it), but not launching
> it from ShellExecuteEx (or similar) with the "/INSTALL"
> parameter, as I would like to check if it's installed
> successfully! But I didn't find any useful API...

The "/install" parameter simply indicates that service executable should
call the Win32 API function CreateService() with the relavant values, and
then terminate the executable afterwards without actually running the
service.  If you know all of the setup values you want to use for the
service, then you can simply all CreateService() yourself directly.

> So I thought to install it that way, and the using the
> OpenSCManager and OpenService functions to check
> the installation result

That is another viable possibility, yes.

> but OpenService always fails and GetLastError always
> reports ERROR_SERVICE_DOES_NOT_EXIST

What does your exact code look like?  You're most likely not passing the
service name correctly.

> by the way what's the difference with ERROR_INVALID_NAME?

They mean exactly what their names suggest:

ERROR_SERVICE_DOES_NOT_EXIST means that the requested service does not
exist.

ERROR_INVALID_NAME means that the requested name itself is not formatted
correct (most likely has invalid characters in it) and thus the attempt to
open the service cannot proceed.

> Obviously I tried to change the dwDesiredAccess
> parameter, but the result does not change!

What does your EXACT code look like?


Gambit
Technical Details
Message-ID: <3ed28fd7$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3ed1e176@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,2bef8d34fe764e59
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-26 15:24:34 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3ed1e176@newsgroups.borland.com>
Subject: Re: Troubles with services
Date: Mon, 26 May 2003 15:08:55 -0700
Lines: 64
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: 207.175.226.26
Message-ID: <3ed28fd7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1053986775 207.175.226.26 (26 May 2003 15:06:15 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail