Get a description of the service?

How can I get a description of a windows service as shown below?

enter image description here

I tried using the Windows registry, but most services don't seem to have a description, or the description value is stored in a dll - so this seems to be the wrong approach.

Example:

Windows Time Service (W32Time), a description in the registry displays as

@% SystemRoot% \ system32 \ w32time.dll, -201

However, the actual description, as shown in Services.msc, is as follows:

Supports date and time synchronization on all clients and servers on the network. If this service is stopped, date and time synchronization will be unavailable. If this service is disabled, any services that explicitly depend on it will not start.

-

I searched on the MSDN website and came across this:

SERVICE_DESCRIPTION structure

lpDescription

Description of the service. If this member is NULL, the description remains unchanged. If this value is an empty string ("), the current description is deleted.

The service description must not exceed the size of a REG_SZ registry value.

This member can specify a localized string using the following format:

@ [path] DllName, -strID

A string with the identifier strID is loaded from dllname; optional path. For more information, see RegLoadMUIString ....

-

pszOutBuf [out, optional]

Pointer to a buffer that receives a string.

Lines of the following type receive special processing:

@ [path] \ DllName, -strID

A string with the identifier strID is loaded from dllname; optional path. If pszDirectory is not NULL, the directory is added to the path specified in the registry data. Note that dllname may contain environment variables that need to be deployed.

What I think would suggest why a registry scan showed a description of W32Time as @% SystemRoot% \ system32 \ w32time.dll, -201

If I understand correctly, I need to read the dll name in memory and extract strID, where is the service description stored?

It all baffles me, I would appreciate it if someone could help.

All I need to do is get a description of the Service, it certainly cannot be as complicated as it can be?

Thanks:)

+4
source share
5 answers

In all versions of Delphi, the JEDI JCL contains everything you need to get friendly service descriptions, and something else related to the service management API.

The TJclSCManager class in the JclSvcCtrl.pas module contains the Services property, which includes the name and description of each registered service and also allows you to perform functions such as starting, stopping, enabling and disabling services.

Refresh . Another answer here from ldsandon indicates that Delphi RTL seems to include this already in XE2, in the WinSvc subsection. See the answer below about QueryServiceConfig2. Thanks to ldsandon for pointing this out.

+3
source

Call QueryServiceConfig2 (here you will also find an example of C).

Everything you need to do with the services must be done using the Service Manager API . Registry data should be considered as "private" for the OS.

+4
source

Using WMI is another way to directly use the Windows API, for example using the (free) API Code Generator

WMI Delphi Code Creator

The WMI tool Delphi Code Creator allows you to create Object Pascal and C ++ code to access WMI (Windows Management Instrumentation) classes, events, and methods.

+2
source

Using Unicode? The notes for the RegLoadMUIString function say that only the Unicode version is supported.

The RegLoadMUIString function is supported only for Unicode. Although both Unicode (W) and ANSI (A) versions of this function are declared, the RegLoadMUIStringA function returns ERROR_CALL_NOT_IMPLEMENTED. Applications must explicitly call RegLoadMUIStringW or specify Unicode as the character set in the platform call call (PInvoke).

Have you tried calling RegLoadMUIStringW directly?

+1
source

You can also check out the GLibWMI library . Free (and source) library for working with WMI. Turn on the component named TServiceInfo . Also included is a demo version for working with wirh services.

With this component you can access the Win32_Service class; You can check the properties and structure here .

Hi

0
source

Source: https://habr.com/ru/post/1394710/


All Articles