From: Fish in a Barrel on
I'm trying to stop a service, if the service exists.

Everything works fine if the service is there, but if it does not
exist I'm getting inconsistent results. OpenService returns a zero
handle, naturally. On some computers (but not all) GetLastError
returns ERROR_SUCCESS instead of ERROR_SERVICE_DOES_NOT_EXIST.

Why would I be getting this combination of returns?
From: Joseph M. Newcomer on
To determine what the cause might be, it is important to know what "some computers" are.
For each one that fails and each one that succeeds, it is important to know

OS version
Service Pack Installed
Hot Fixes installed

Does the service exist in the Registry at the time of call even if there is no executable
installed?

These are a few questions which would have to be answered before any progress could be
made.
joe

On Mon, 5 May 2008 09:04:20 -0700 (PDT), Fish in a Barrel <aaron.m.johnson(a)gmail.com>
wrote:

>I'm trying to stop a service, if the service exists.
>
>Everything works fine if the service is there, but if it does not
>exist I'm getting inconsistent results. OpenService returns a zero
>handle, naturally. On some computers (but not all) GetLastError
>returns ERROR_SUCCESS instead of ERROR_SERVICE_DOES_NOT_EXIST.
>
>Why would I be getting this combination of returns?
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm