dllcall for Service Description

Started by bkeadle, March 02, 2017, 12:22:02 PM

Previous topic - Next topic

bkeadle

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:


td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

ChuckC

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?



bkeadle

That did the trick, wntSvcCfgGet().  Thank you!

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

ChuckC