Reboot the video driver. Is it even possible?

Some drivers use registry settings to configure when they load at boot time. I can change these values ​​and then reload, but I would like to know if the driver can be reloaded by making the changes effective without rebooting.

In particular, we are talking about a video driver (nvidia).

I read somewhere that a call through pINvoke () [User32.ll] :: ChangeDisplaySettings () with a resolution of 640x480x8bit (which is so low that it should not be supported by a modern driver) will force the windows to load the "Standard VGA driver", and another call with the current resolution, the nvidia driver will load again.

This does not work. At least in Windows 7, even if the low resolution does not appear as “supported,” the system reduces the screen to a small square in the center of the screen, showing low values ​​when the nvidia driver is unloaded.

So, is there any .NET / Win32 API, a service to reboot, or in any way to reboot the video driver?

Perhaps turning off the device programmatically (as you could from the device manager) and re-enabling it again?

Any idea?

Many thanks.

+4
source share
2 answers

I finally did it. Following the idea of ​​disconnecting / reconnecting, the device actually worked.

Of course, the problem is that disconnecting your video card device from the device manager may not be a great idea, because you may not be able to reuse it again.

Doing this programmatically until it seems so unsafe. Theoretically, assuming that the application successfully disconnected the device, re-enabling it should not cause problems.

I found a fantastic class here in stackoverflow to achieve this, thanks to Justin Grant.

The video driver restarts when the video device is reconnected.

Hope this helps someone.

+2
source

It depends on the driver. If it was written to support stopping and restarting, then this is possible; otherwise you are out of luck. If you find the service name, you can execute "sc stop [name]" and then "sc start [name]". Win32 equivalent is OpenService / ControlService.

+1
source

Source: https://habr.com/ru/post/1304882/


All Articles