Unloading a driver on WinNT 4.0

Hi everyone,

My question is related to unloading a driver from an application in
Windows NT 4.

Is there a way to remove a driver from an application. Does it require
any priveleges, if it does what priveleges does it require?

I tried remove the device from the Network Control Panel and it did
remove the device and the registry entries but the Driver Service was
not stopped and the driver was still running and connected to the
network. ( I tried a Ping and it worked after i removed the device). Is
it compulsory to restart the system? Cant i bring down the driver with
out restarting?

Thanks in advance
Sriram


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Use Service Control Manager functions:
OpenSCManager(), OpenService(), ControlService(, SERVICE_CONTROL_STOP, ),
then wait until service stops. You can periodically check service status
with QueryServiceStatus().
Then call DeleteService() and CloseServiceHandle().
At this point service should be removed if it stopped correctly and no other
open handles to it exist.

AFAIK you have to be a member of local Administrators to have privilege for
stopping and removing a service.

-----Original Message-----
From: Sriram Narasimhan [mailto:xxxxx@tataelxsi.co.in]
Sent: Tuesday, January 22, 2002 5:04 PM
To: NT Developers Interest List
Subject: [ntdev] Unloading a driver on WinNT 4.0

Hi everyone,

My question is related to unloading a driver from an application in
Windows NT 4.

Is there a way to remove a driver from an application. Does it require
any priveleges, if it does what priveleges does it require?

I tried remove the device from the Network Control Panel and it did
remove the device and the registry entries but the Driver Service was
not stopped and the driver was still running and connected to the
network. ( I tried a Ping and it worked after i removed the
device). Is
it compulsory to restart the system? Cant i bring down the driver with
out restarting?

Thanks in advance
Sriram


You are currently subscribed to ntdev as: xxxxx@previo.ee
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Thank you.
I tried this but ControlService(, SERVICE_CONTROL_STOP, ) failed. Can you tell
me why? Should this
be put in a loop until it succeeds? How do i know if it really failed or the
service is still under the process of shutting down.

I first tried manually by going to the device service panel. And then stopping
the device. At this point I got an error
Error 2186 : The service is not responding to the control function.

I believe there is a time out value. But if there is a way to increase the time
out value using
ControlService, can you tell me how to do it.

Sriram

Grigori Shpakov wrote:

Use Service Control Manager functions:
OpenSCManager(), OpenService(), ControlService(, SERVICE_CONTROL_STOP, ),
then wait until service stops. You can periodically check service status
with QueryServiceStatus().
Then call DeleteService() and CloseServiceHandle().
At this point service should be removed if it stopped correctly and no other
open handles to it exist.

AFAIK you have to be a member of local Administrators to have privilege for
stopping and removing a service.

> -----Original Message-----
> From: Sriram Narasimhan [mailto:xxxxx@tataelxsi.co.in]
> Sent: Tuesday, January 22, 2002 5:04 PM
> To: NT Developers Interest List
> Subject: [ntdev] Unloading a driver on WinNT 4.0
>
>
> Hi everyone,
>
> My question is related to unloading a driver from an application in
> Windows NT 4.
>
> Is there a way to remove a driver from an application. Does it require
> any priveleges, if it does what priveleges does it require?
>
> I tried remove the device from the Network Control Panel and it did
> remove the device and the registry entries but the Driver Service was
> not stopped and the driver was still running and connected to the
> network. ( I tried a Ping and it worked after i removed the
> device). Is
> it compulsory to restart the system? Cant i bring down the driver with
> out restarting?
>
> Thanks in advance
> Sriram
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@previo.ee
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Your driver should have Unload function specified in DRIVER_OBJECT.
When you try to stop the driver, its Unload function is being called. If
Unload function is missing then you will probably get such error code, as
you wrote.
Look DDK help for details.

-----Original Message-----
From: Sriram Narasimhan [mailto:xxxxx@tataelxsi.co.in]
Sent: Tuesday, January 22, 2002 5:38 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Unloading a driver on WinNT 4.0

Thank you.
I tried this but ControlService(, SERVICE_CONTROL_STOP, )
failed. Can you tell
me why? Should this
be put in a loop until it succeeds? How do i know if it
really failed or the
service is still under the process of shutting down.

I first tried manually by going to the device service panel.
And then stopping
the device. At this point I got an error
Error 2186 : The service is not responding to the control function.

I believe there is a time out value. But if there is a way to
increase the time
out value using
ControlService, can you tell me how to do it.

Sriram

Grigori Shpakov wrote:

> Use Service Control Manager functions:
> OpenSCManager(), OpenService(), ControlService(,
SERVICE_CONTROL_STOP, ),
> then wait until service stops. You can periodically check
service status
> with QueryServiceStatus().
> Then call DeleteService() and CloseServiceHandle().
> At this point service should be removed if it stopped
correctly and no other
> open handles to it exist.
>
> AFAIK you have to be a member of local Administrators to
have privilege for
> stopping and removing a service.
>
> > -----Original Message-----
> > From: Sriram Narasimhan [mailto:xxxxx@tataelxsi.co.in]
> > Sent: Tuesday, January 22, 2002 5:04 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Unloading a driver on WinNT 4.0
> >
> >
> > Hi everyone,
> >
> > My question is related to unloading a driver from an
application in
> > Windows NT 4.
> >
> > Is there a way to remove a driver from an application.
Does it require
> > any priveleges, if it does what priveleges does it require?
> >
> > I tried remove the device from the Network Control Panel
and it did
> > remove the device and the registry entries but the Driver
Service was
> > not stopped and the driver was still running and connected to the
> > network. ( I tried a Ping and it worked after i removed the
> > device). Is
> > it compulsory to restart the system? Cant i bring down
the driver with
> > out restarting?
> >
> > Thanks in advance
> > Sriram
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@previo.ee
> > To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
>
> —
> You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@previo.ee
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com