强制 Windows 视频驱动程序重新加载。有可能吗?
某些驱动程序在启动时加载时使用注册表中写入的参数来配置自身。 我可以修改这些值然后重新启动,但我想知道是否可以强制重新加载驱动程序,使更改在不重新启动的情况下生效。
具体来说,我正在谈论视频驱动程序(nvidia)。
我在某处读到,通过 pINvoke() [User32.ll]::ChangeDisplaySettings() 调用 640x480x8 位分辨率(分辨率太低,现代驱动程序不支持)将强制 Windows 加载“标准 VGA” driver”,并使用当前分辨率再次调用将再次加载 nvidia 驱动程序。
但这不起作用。至少在 Windows 7 中,即使低分辨率未显示为“支持”,系统也会将屏幕缩小到屏幕中央的一个小正方形,从而在不卸载 nvidia 驱动程序的情况下显示低分辨率。
那么,是否有任何 .NET/Win32 API、要重新启动的服务或任何方法来强制重新加载视频驱动程序?
也许以编程方式禁用设备(就像您可以从设备管理器中执行的那样)并再次重新启用它?
有什么想法吗?
多谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我终于做到了。遵循禁用/重新启用设备的想法实际上是有效的。
当然,问题是从设备管理器禁用视频卡设备并不是一个好主意,因为您可能无法再次重新启用它。
不过,以编程方式执行此操作似乎并不那么不安全。理论上,假设应用程序已成功禁用设备,重新启用它应该不会造成问题。
我发现这里,在stackoverflow中非常棒< /strong> 类来完成此任务,感谢 Justin Grant。
当视频设备重新启用时,视频驱动程序会自行重新加载。
希望它能帮助某人。
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.
这取决于司机。如果它是为了支持停止和重新启动而编写的,那么这是可能的;否则,你就不走运了。如果找到服务的名称,可以执行“sc stop [name]”,然后执行“sc start [name]”。 Win32 等效项是 OpenService/ControlService。
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.