强制 Windows 视频驱动程序重新加载。有可能吗?

发布于 2024-08-26 18:33:16 字数 518 浏览 6 评论 0原文

某些驱动程序在启动时加载时使用注册表中写入的参数来配置自身。 我可以修改这些值然后重新启动,但我想知道是否可以强制重新加载驱动程序,使更改在不重新启动的情况下生效。

具体来说,我正在谈论视频驱动程序(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

魔法唧唧 2024-09-02 18:33:17

我终于做到了。遵循禁用/重新启用设备的想法实际上是有效的。

当然,问题是从设备管理器禁用视频卡设备并不是一个好主意,因为您可能无法再次重新启用它。

不过,以编程方式执行此操作似乎并不那么不安全。理论上,假设应用程序已成功禁用设备,重新启用它应该不会造成问题。

我发现这里,在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.

山有枢 2024-09-02 18:33:17

这取决于司机。如果它是为了支持停止和重新启动而编写的,那么这是可能的;否则,你就不走运了。如果找到服务的名称,可以执行“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文