?
Solved

How to unload/reload a driver from Win32

Posted on 2003-03-03
2
Medium Priority
?
390 Views
Last Modified: 2010-04-17
Hello,
Any pointers as how to unload or reload a device driver from a Win32 application.  TIA.
0
Comment
Question by:chu_bun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
mosquitooth earned 800 total points
ID: 8066403
OK. This loads a driver:

SC_HANDLE hService = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);

SC_HANDLE hService2 = OpenService(hService,"YourDriver",SERVICE_ALL_ACCESS);

SERVICE_STATUS servstat;
QueryServiceStatus(hService2,&servstat);
 
if(servstat.dwCurrentState == SERVICE_STOPPED)
{
  StartService(hService2,0,NULL);
}

Unloading is quite simple, only change to checking if dwCurrentState != SERVICE_STOPPED. Then call:

ControlService(hService2,SERVICE_CONTROL_STOP,&servstat);

Hope this helps
mosquitooth
0
 

Author Comment

by:chu_bun
ID: 8073295
I never thought it was that simple.  Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question