-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to call QueryServiceConfig? #47
Comments
In nim, I modified your code: import winim/lean
import strformat except `&`
import strutils
const SERVICE_EXAMPLE = "SysMain"
proc main =
var sc = OpenSCManager(nil, nil, SERVICE_QUERY_CONFIG)
echo fmt"OpenSCMAnager: {GetLastError()}"
defer:
if sc != 0: CloseServiceHandle(sc)
var os = OpenService(sc, SERVICE_EXAMPLE, SERVICE_QUERY_CONFIG)
echo fmt"OpenService: {GetLastError()} : os: {os}"
defer:
if os != 0: CloseServiceHandle(os)
var bytesNeeded: DWORD
QueryServiceConfig(os, nil, 0, &bytesNeeded)
echo fmt"QueryServiceConfig: {GetLastError()}"
var buffer = newString(bytesNeeded)
let lpServiceConfig = cast[LPQUERY_SERVICE_CONFIG](&buffer)
QueryServiceConfig(os, lpServiceConfig, bytesNeeded, &bytesNeeded)
echo fmt"Let's print the path {bytesNeeded}"
echo lpServiceConfig.lpBinaryPathName
when isMainModule:
main()
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I'd like to call QueryServiceConfig to get some more info about the running service.
I am not sure what I am doing wrong..I am getting error code 6 (ERROR_INVALID_HANDLE) for OpenService...but...I guess I just dont know what I am doing.
)
The text was updated successfully, but these errors were encountered: