美文网首页
反安装驱动

反安装驱动

作者: wyrover | 来源:发表于2016-08-31 15:24 被阅读73次

    安装过的驱动会在 C:\Windows\inf 路径下生成 oemxx.inf,直接删除 oemxx.infoemxx.PNF 是卸载不了驱动,应该使用 SetupUninstallOEMInf 函数。在 vista 以上平台 pnputil.exe 可以卸载驱动但是正在使用的驱动不再卸载。使用 -f -d 可以强制删除。传递 SUOI_FORCEDELETE 参数到 SetupUninstallOEMInf 函数是不可取的,他在会注册表里结束你的 devnodes

    You should use the SetupUninstallOEMInf function to uninstall the .INF (and subsequently .PNF) files. This will take care of the details. pnputil
    (on Vista and higher) should do the equivalent thing from the command line. However, this function will not delete drivers that are currently installed (e.g. associated with a devnode).
    Why are you uninstalling the old driver first? The user might already installed your driver for at least one devnode. Why not use a Microsoft-sanctioned solution such as DpInst
    ? It will do the work required to update the driver.

    Passing SUOI_FORCEDELETE
    to SetupUninstallOEMInf
    wouldn't be a good idea, cause you'd end up with lingering .INF references in your devnodes (in the registry).

    At work I wrote a utility I called DriverUninstaller that deletes the devnodes and then deleted the INFs. I only use this utility for uninstallations. Upgrades are handled by DpInst, as they should be. The flow is roughly:

    1. Enumerate them with SetupAPI (e.g. by device class if your device class is unique)
    2. For each devnode, call SetupDiCallClassInstaller(DIF_REMOVE, ...)
    3. Call SetupDiBuildDriverInfoList
      to find all .INF files for my device
    4. For each INF, call SetupUninstallOEMInf

    links

    相关文章

      网友评论

          本文标题:反安装驱动

          本文链接:https://www.haomeiwen.com/subject/ifoqettx.html