Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: XE7: TService not properly registering in Windows Service Control Panel


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Dec 2, 2014 10:44 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Mike Knoblock

Posts: 24
Registered: 11/5/06
XE7: TService not properly registering in Windows Service Control Panel  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 2, 2014 8:30 AM
My last windows service project was in RAD Studio 2010. In that project the service would appear in the service control panel as "UDP Logger Service", and the name of the service itself was "svcUdpLogger". These values were the 'Display Name' and 'Name' of the TService class object respectively. These unique names are displayed in the service properties as expected (double click on the service name in SCP). So far so good.

In XE7, only the Name property of the TService class is propagated to the SCP, and it's duplicated as the service display name and the class name itself.

There are three name-oriented properties in TService:
DisplayName: Should be the 'regular' name of the service as it appears in the SCP
Name: name of the TService class itself
ServiceStartName: I don't know what this does, and a string in this place does not appear anywhere I can find.

Only the 'Name' property shows up in the SCP. Did something change in the class naming convention for TService between RS2010 and XE7?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: XE7: TService not properly registering in Windows Service Control Panel  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 2, 2014 10:44 AM   in response to: Mike Knoblock in response to: Mike Knoblock
Mike wrote:

ServiceStartName: I don't know what this does, and a string in this
place does not appear anywhere I can find.

It specifies the user account that the service runs as. If blank, the SYSTEM
account is used.

Did something change in the class naming convention for TService between
RS2010 and XE7?

The only changes that have been made to the SvcMgr unit between 2010 and
XE7 are:

- the addition of Unit Scope names.
- data type corrections (Integer -> DWORD, LPSTR -> LPWSTR, etc)
- {$IFEND} changed back to {$ENDIF} as {$IFEND} is now deprecated.
- use of MessageDlg() is disabled when TService is running in a console process.

No logic changes have been made otherwise. And certainly nothing has changed
regarding service installation. It still uses the Win32 API CreateService()
function, and it still passes the TService.DisplayName property value as-is
to the lpDisplayName parameter.

In fact, the entire SvcMgr unit as a whole has changed very little since
it was first introduced in C++Builder/Delphi 5. Most of the updates are
to account for .NET support and compiler/RTL changes. Consequently, TService
still cannot take advantage of many of the new features that have been introduced
since Win2K.

Now, that being said, the TService::DisplayName property uses a getter method
that returns (and has always returned) the value of the TService::Name property
when a non-blank value has not been assigned to the TService::DisplayName
property beforehand. Turns out that the RTL has a bug going all the way
back to at least XE2 (when some RTTI functions used by the DFM streaming
system were re-written) which causes certain UnicodeString values stored
in a DFM to not be streamed correctly at run-time, but it only happens in
C++Builder (it works fine in Delphi). The TService::DisplayName property
is affected by this bug. Its design-time value does not get assigned to
the property at run-time, so it is blank when CreateService() is beign called,
and thus the TService::Name property value gets assigned to the SCM instead.

This problem was discussed in detail earlier this year:

TService DisplayName does not show in the Service control manager
https://forums.embarcadero.com/thread.jspa?threadID=105238

In particular, here is my analysis when I traced into the problem:

https://forums.embarcadero.com/thread.jspa?threadID=105238#656046

As a workaround, you can use the TService::BeforeInstall event to manually
assign your desired string value to the TService::DisplayName property, and
then it won't be blank anymore when CreateService() is called.

AFAIK, the bug never got reported to QualityCentral or QualityPortal yet.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02