Force windows video driver reload. Is it possible at all?

泪湿孤枕 提交于 2020-01-03 15:55:29

问题


Some drivers use parameters written in the registry to configure themselves when they get loaded at boot time. I can modify those values and then reboot, but I would like to know if it is possible to force the driver reload, making the changes effective without rebooting.

Specifically, I am talking about the video driver (nvidia).

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

This does not work though. At least in Windows 7, even if the low res is not displayed as "supported" the system reduces the screen to a little square in the center of the screen, showing the low res wihtout unloading the nvidia driver.

So, is there any .NET/Win32 API, service to restart, or any way at all to force a video driver reload?

Perhaps programatically disabling the device (as you could do from the Device Manager) and reenabling it again?

Any idea?

Thanks a lot.


回答1:


I finally did it. Following the idea of disabling/reenabling the device actually worked.

Of course the problem is that disabling your video card device from the Device Manager could not be a great idea, as maybe you are not able to reenable it again.

Doing it programatically, does not appear so unsafe though. In theory, asuming that the app has successfully disabled the device, reenabling it should not pose a problem.

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

The video driver reloads itself as the video device is reenabled.

Hope it helps someone.




回答2:


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



来源:https://stackoverflow.com/questions/2500411/force-windows-video-driver-reload-is-it-possible-at-all

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!