Experts!
I have a device conected to my computer with a USB,
i want to stop this device and then start it again.
i selected disable in the device manager and the device was disable
successfully.

But when i tried to do it programmaticatly it failed.
I tried calling "net stop service_name_blabla" from the command line.
and i tried using SERVICE_CONTROL_STOP,in ControlService

but they both failed, reason:
"The requested control is not valid for this service. " error
how can i disable the service with C++ like i'm doing well in the device
manager ?

thanks.

RE: Stop Service by pavel_a

pavel_a
Mon Jun 19 04:34:01 CDT 2006

"Bombadill" wrote:
.....
> I tried calling "net stop service_name_blabla" from the command line.
> and i tried using SERVICE_CONTROL_STOP,in ControlService
>
> but they both failed, reason:
> "The requested control is not valid for this service. " error
> how can i disable the service with C++ like i'm doing well in the device
> manager ?

Driver is not a normal service, so you can't stop it with ControlService.
Use SetupDi... API. See the "devcon" sample in DDK for this.

Regards,
--PA


Re: Stop Service by Maxim

Maxim
Mon Jun 19 14:06:20 CDT 2006

> But when i tried to do it programmaticatly it failed.
> I tried calling "net stop service_name_blabla" from the command line.
> and i tried using SERVICE_CONTROL_STOP,in ControlService

Not correct way. See DEVCON source for a correct way, which is the same as
"Disable" in Device Manager - SetupDiCallClassInstaller with proper function
code.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com