我的 .INF 的卸载部分
我正在努力扩展现有的 USB 设备驱动程序,并且一直在努力了解 .INF 文件的工作原理。我相信我现在已经拥有了,驱动程序已安装并可以工作。它还显示在“添加/删除程序”列表中。
我发现当我从“添加/删除”中卸载驱动程序时,它似乎几乎没有什么作用。这是在 .INF 中,因为我继承了它:
[myUninstall]
DelReg = myDelReg
[MyDelReg]
HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\myName"
我找不到其他引用,甚至找不到注册表卸载中安装“myName”的位置。
我已将 .INF 更改为具有以下内容:
[DefaultUninstall]
myUninstall
[myUninstall]
DelFiles = ... a list of files ...
DelDirs = UNINST.Dirs
DelReg = UNINST.Regs
Cleanup = 1
[UNINST.Dirs]
%16422%\%InstallDir%
[UNINST.Regs]
myDev.AddReg
myDev.CommonRegs
[myDev.AddReg] ; same definition used for installing
HKR,,Drivers,Subclasses,,"wave,midi,mixer,aux"
...
[myDev,CommonRegs] ; same definition used for installing
HKR, Parameters, BufferSize, 0x0010001, 256
...
尽管如此,无论我从控制面板添加/删除程序卸载还是从设备管理器卸载,系统都不会抱怨,并且似乎什么也没有发生。我查看了“dpinst /c”的输出和 setupapi.log,但都没有告诉我太多信息。 dpinst 显示没有错误,但显然甚至没有尝试执行我的卸载部分。
我在网上找到了很多卸载部分的废话和示例,但解释的很少。我今天在 1 个论坛中偶然发现了一句话,暗示 PnP 设备 .INF 不使用卸载。也许这是我的问题?
- 我是否错误地认为我可以在此 .INF 中卸载?
- 还有其他方法可以告诉发生了什么吗?
- 我唯一的办法就是编写一个单独的卸载程序吗?
I'm working on extending an existing USB device driver, and have been struggling learn how the .INF file works. I believe that I have it right now, the driver installs and works. It also shows up in the "Add/Remove Programs" list.
I find that when I uninstall the driver from Add/Remove, it seems to do little if anything. This was in the .INF as I inherited it:
[myUninstall]
DelReg = myDelReg
[MyDelReg]
HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\myName"
I can find no other references, not even where "myName" is installed in the registry Uninstall.
I've changed the .INF to have this:
[DefaultUninstall]
myUninstall
[myUninstall]
DelFiles = ... a list of files ...
DelDirs = UNINST.Dirs
DelReg = UNINST.Regs
Cleanup = 1
[UNINST.Dirs]
%16422%\%InstallDir%
[UNINST.Regs]
myDev.AddReg
myDev.CommonRegs
[myDev.AddReg] ; same definition used for installing
HKR,,Drivers,Subclasses,,"wave,midi,mixer,aux"
...
[myDev,CommonRegs] ; same definition used for installing
HKR, Parameters, BufferSize, 0x0010001, 256
...
Still, whether I uninstall from the Control Panel Add/Remove programs or do it from the device manager, the system doesn't complain and nothing seems to happen. I've looked at the output of "dpinst /c" and the setupapi.log, and neither tell me much. dpinst shows no error but is clearly not even trying to execute my uninstall section.
I find a lot of verbiage online and examples of uninstall sections, but very little in the way of explanation. I did stumble across one sentence in 1 forum today that implied that PnP device .INF's don't use Uninstall. Perhaps this is my issue?
- am I wrong in thinking that I can have Uninstall in this .INF?
- is there some other way to tell what is happening?
- is my only recourse to write a separate uninstaller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
AFIK,INF 文件不参与卸载。
如果您想执行正确的清理,您将需要编写一个单独的卸载程序。
进一步请注意,对于 Vista 及更高版本,Windows 还包含一个驱动程序存储区,它会在其中默默地复制驱动程序包(inf 和来自 inf 的文件引用)。如果要执行完全清理,驱动程序存储区也应该被清理。
AFIK, the INF files do not participate in uninstallation.
You will need to write a separate uninstaller if you want to perform proper cleanup.
Further note that with Vista and beyond, Windows also includes a Driver Store, where it silently copies the driver package (inf and files references from the inf). If you want to perform a full cleanup, the driver store should also be cleaned up.
我不认为
DefaultUninstall
是像DefaultInstall
那样的标准部分。通常,您会看到UninstallString
ARP 条目仅按名称调用DefaultUninstall
。该领域的文档非常糟糕,基本的 SetupAPI/SetupX INF 文件和高级 INF 文件 (AdvPack) 之间存在分歧。
据我所知,唯一的第 3 方例外是 Windows 95 PowerToys 中的 TweakUI.inf。
它的部分如下所示:
但我认为这只适用于可选组件功能,不适用于基本卸载。 TweakUI v1.33(Tweakui.exe SFX 存档)有更多与 NT 相关的条目,我相信它为 NT 编写
UninstallString
的方式甚至写入了错误的 INF 部分。不管错误与否,它必须手动指定一个 INF 部分才能正常卸载。I don't think
DefaultUninstall
is a standard section in the wayDefaultInstall
is. Often you will see theUninstallString
ARP entry just callingDefaultUninstall
by name.The documentation in this area is pretty bad and there is a split between the basic SetupAPI/SetupX INF files and the Advanced INF files (AdvPack).
The only 3rd-party exception I know of is TweakUI.inf from the Windows 95 PowerToys.
It has parts that look like this:
But I think that only works with the optional components feature, not basic uninstallation. TweakUI v1.33 (Tweakui.exe SFX archive) has some more NT related entries and I believe the way it writes the
UninstallString
for NT even writes the wrong INF section. Wrong or not, it manually has to specify a INF section for normal uninstall.因此,inf 文件可用于执行一些卸载操作,但基本上您只是在卸载时手动调用 inf 文件中的任意部分。
所以如果你运行这个:
并且你的 inf 文件中有一个部分:
那就有效了。请注意,这会破坏整个通用 INF 的情况,因为您不能在通用 inf 文件中执行 Delreg 操作。
So the inf file can be used to perform some uninstallation actions, but basically you're just manually calling an arbitrary section in the inf file at uninstall time.
So if you run this:
and you have a section in your inf file:
that works. Just note that this breaks the whole Universal INF thing because you can't have a Delreg action in a universal inf file.