WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: bkeadle on March 02, 2017, 12:22:02 PM

Title: dllcall for Service Description
Post by: bkeadle on March 02, 2017, 12:22:02 PM
Service descriptions used to be easily read from the registry, but now I see many service descriptions are using string redirection, e.g. "@%SystemRoot%\System32\hidserv.dll, -102".  I *think* I need to use DllCall to retrieve the service description from the specified .DLL?  I have no idea how to go about doing this.

I have a utility that prepends the Service Description with the current startup and running state which makes troubleshooting service statuses (and new services) easy.  But with the string redirection, it makes the result ugly:
(https://dl.dropboxusercontent.com/u/13871375/Winbatch/servicedescriptions.png)
Title: Re: dllcall for Service Description
Post by: td on March 02, 2017, 01:23:53 PM
Assuming by redirection you are referring to the %SystemRoot% environmental variable in the path, you don't need to use  any DllCall calls.  You can use the  RegQueryExpSz function if the registry value is of type REG_EXPAND_SZ or you can perform a string replacement on the value yourself by using the Enviroment function to get the current value of SystemRoot and use StrReplace to perform the string replacement.  Just remember to escape the percent ('%') character with 2 percent signs ('%%') in any string literals.
Title: Re: dllcall for Service Description
Post by: ChuckC on March 03, 2017, 07:38:14 AM
What kind of string value do you get when you use the Win32 Network Extender's wntSvcCfgGet() function with Request # 10 to retrieve the service description?  Is it returning the proper description value that you'd expect to see, or is it returning the same redirection string that's stored in the registry?


Title: Re: dllcall for Service Description
Post by: bkeadle on March 03, 2017, 08:50:48 AM
That did the trick, wntSvcCfgGet().  Thank you!
Title: Re: dllcall for Service Description
Post by: td on March 03, 2017, 09:05:34 AM
Thanks Chuck.
Title: Re: dllcall for Service Description
Post by: ChuckC on March 03, 2017, 09:07:00 AM
you're welcome :)