相当于在 Windows XP 或更高版本中以编程方式从文件夹安装驱动程序

发布于 2024-10-21 21:57:16 字数 515 浏览 4 评论 0原文

我需要在客户的计算机上安装驱动程序。不幸的是,现在执行此操作的唯一方法是让 Windows 在设备插入时显示其“硬件更新向导”,然后让用户执行以下操作:

  • 选择“否,这次不”,
  • 选择“从特定位置(高级)”,
  • 选中或取消选中适当的复选框,然后选择包含驱动程序的文件夹

。所有这些对于不懂技术的用户来说都是缓慢且不友好的。对于必须在多台计算机上安装该设备的人来说,这也是一个重复且烦人的过程。

因此,我正在尝试编写一个非常简单的程序来提示用户插入设备。然后程序会自动执行上面相同的步骤。我的问题:

  • 我想知道是否有一个 Windows API 可以在文件夹中查找驱动程序,因为这就是向导的作用。
  • 我刚刚发现了 DriverPackageInstall 函数。将 .inf 文件作为参数传递会达到我想要的效果吗? (同时我将编写代码来测试这一点,请给我一些时间下载 Windows 驱动程序工具包并设置一个项目...)。
  • 还有其他建议吗?

I need to have a driver installed in my customers' computers. Unfortunately, the only way to do this right now is having Windows show its "Hardware Update Wizard" when the device is plugged in, and then have the user do the following:

  • select "No, not this time",
  • select "Install from a specific location (Advanced)",
  • check or uncheck appropriate checkboxes and select the folder that contains the drivers

All of which is slow and unfriendly for a non technically savvy user. For the people who must install the device in many computers, it's a repetitive and annoying process too.

So, I'm trying to write a very simple program that will prompt the user to plug in the device. Then the program will do the same steps above automatically. My questions:

  • I wonder if there is a Windows API that looks for drivers in a folder, since that's what the Wizard does.
  • I've just discovered the function DriverPackageInstall. Would passing the .inf file as a parameter do what I want? (I'll be writing code to test this in the meanwhile, just give me some time to download the Windows Driver Kit and set up a project...).
  • Any other suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

菩提树下叶撕阳。 2024-10-28 21:57:16

您没有指定 Windows 的版本。

在 Windows 7 上,有 pnputil:

c:\>pnputil -?
Microsoft PnP Utility
Usage:
------
pnputil.exe [-f | -i] [ -? | -a | -d | -e ] <INF name>
Examples:
pnputil.exe -a a:\usbcam\USBCAM.INF      -> Add package specified by USBCAM.INF
pnputil.exe -a c:\drivers\*.inf          -> Add all packages in c:\drivers\
pnputil.exe -i -a a:\usbcam\USBCAM.INF   -> Add and install driver package
pnputil.exe -e                           -> Enumerate all 3rd party packages
pnputil.exe -d oem0.inf                  -> Delete package oem0.inf
pnputil.exe -f -d oem0.inf               -> Force delete package oem0.inf
pnputil.exe -?                           -> This usage screen

以编程方式,您可以使用 DiInstallDriver

You did not specify which version of Windows.

On Windows 7 there`s pnputil:

c:\>pnputil -?
Microsoft PnP Utility
Usage:
------
pnputil.exe [-f | -i] [ -? | -a | -d | -e ] <INF name>
Examples:
pnputil.exe -a a:\usbcam\USBCAM.INF      -> Add package specified by USBCAM.INF
pnputil.exe -a c:\drivers\*.inf          -> Add all packages in c:\drivers\
pnputil.exe -i -a a:\usbcam\USBCAM.INF   -> Add and install driver package
pnputil.exe -e                           -> Enumerate all 3rd party packages
pnputil.exe -d oem0.inf                  -> Delete package oem0.inf
pnputil.exe -f -d oem0.inf               -> Force delete package oem0.inf
pnputil.exe -?                           -> This usage screen

programmatically, you can use DiInstallDriver

久夏青 2024-10-28 21:57:16

有多种方法,其中一些取决于您拥有的设备类型。

有多种用于安装驱动程序包的工具。

  1. DpInst 是一个完整的应用程序,可以显示向导并可自定义安装驱动程序包

  2. DifXApp 构建可用于安装驱动程序的 msi 包

  3. DifxApi 是 DpInst 和 DifxApp 用于安装驱动程序的 API。

  4. 直接使用SetupApi函数。

    这里的函数SetupCopyOEMInfUpdateDriverForPlugAndPlayDevices 提供相应的入口点用于驱动程序设置。这些包含在WinSDK 中。

DpInst/DifxApp/DifxApi 是 Windows 驱动程序工具包 (WDK) 的一部分。

There are several ways and some depend on the type of device you have.

There are several tools for installing driver packages.

  1. DpInst is a complete application which can show a wizard and be customized to install a driver package

  2. DifXApp builds a msi package which can be used to install drivers

  3. DifxApi is the API which DpInst and DifxApp use to install drivers.

  4. Directly using the SetupApi functions.

    Here the functions SetupCopyOEMInf and UpdateDriverForPlugAndPlayDevices provide the corresponding entry points for a driver setup. These are contained in the WinSDK.

DpInst/DifxApp/DifxApi are part of the Windows Driver Kit (WDK).

傲影 2024-10-28 21:57:16

DifX(在 Windows DDK 中找到)是 Microsoft 推荐的安装驱动程序的方法。 DPInst 是独立工具,DifX API 是编程方式。

如果驱动程序已签名,您可以使用 DPInst(或 DifX API)预安装它,然后用户插入硬件后就会安装它(没有任何向导或提示)。

如果驱动程序未签名(即没有签名的 .cat 文件),则:

  • 在 Windows Vista 及更高版本上,您可以自己对其进行签名(通常使用从 CA 购买的证书,但也可以进行自签名)
  • 在 Windows XP 上,你注定失败(除非你应用一些真正丑陋的黑客)

DifX (found in the Windows DDK) is the Microsoft recommended way for installing drivers. DPInst is the standalone tool and DifX API is the programmatic way.

If the driver is signed, you can use DPInst (or DifX API) to preinstall it and then it'll be installed (without any wizards or prompts) as soon as the user inserts the hardware.

If the driver is unsigned (i.e. has no signed .cat file), then:

  • on Windows Vista and higher, you can sign it yourself (typically with a certificate you purchase from a CA, though self-signing might be possible)
  • on Windows XP, you're doomed (unless you apply some real ugly hacks)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文