【问题标题】:Update a Windows Mobile Driver更新 Windows Mobile 驱动程序
【发布时间】:2010-11-09 13:57:49
【问题描述】:

我们有用于 Windows Mobile 6.5 的自定义 NDIS 协议和微型端口驱动程序。我们希望允许用户干净地卸载这些驱动程序,但是卸载当前会给出错误:“未完全删除。您想从已安装程序列表中删除它吗?”这可能是因为驱动程序仍在使用中(由远程进程查看器报告)。不幸的是,我无法弄清楚如何卸载驱动程序(假设这是问题所在)。驱动程序适用于设备内置的硬件,因此无法简单地移除设备并卸载驱动程序

  1. 是否有卸载驱动程序的编程方法?
  2. 在卸载时我还应该做些什么来彻底卸载驱动程序?

[编辑] 当我写这篇文章时,我可能应该提到整个问题。我真的很关心更新驱动程序。我不一定要卸载旧驱动程序才能做到这一点。

【问题讨论】:

    标签: windows-mobile device-driver


    【解决方案1】:

    您可能可以调用 DeactivateDevice,尽管您需要拥有驱动程序的句柄(来自任何称为 ActivateDevice 的人)。对于 CE 5.0 及更早版本,至少对于流驱动程序,设备管理器实际上将其放在注册表中 HKLM/Drivers/Active 下。

    我没有寻找 NDIS,因为我从来不想卸载一个。为此,您可能需要使用 IOCTL_NDIS_UNBIND_ADAPTER and/or IOCTL_NDIS_DEREGISTER_ADAPTER 将 DeviceIoControl 调用到 NDIS 驱动程序

    【讨论】:

    • 有趣。 DeactiveDevice 当然可以。我想知道在生产环境中使用它是否会导致任何问题。我会假设 ActivateDevice 的调用者可能希望它仍然存在......
    【解决方案2】:

    一种可能性是在 Windows Mobile 启动时启动一个程序,该程序将删除旧驱动程序并将新驱动程序复制到位。

    这可以使用HKEY_LOCAL_MACHINE\Init 来完成,如下所述:

    这是一个示例程序:

    #include <windows.h>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
       // delete the old driver
       BOOL result = DeleteFile(L"\\Windows\\MyDriver.dll");
       if (result)
       {
          // put the new driver in place
          result = MoveFile(L"\\My Documents\\MyDriver_NEW.dll",
             L"\\Windows\\MyDriver.dll");
       }
    
       // Delete us from the registry
       HKEY regKey = 0;
       LONG regResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"init", 0, KEY_SET_VALUE, &regKey);
       result = regResult == ERROR_SUCCESS;
       if (result)
       {
          regResult = RegDeleteValue(regKey, L"Depend19");
          result = regResult == ERROR_SUCCESS;
          if (result)
          {
             regResult = RegDeleteValue(regKey, L"Launch18");
             result = regResult == ERROR_SUCCESS;
          }
          RegCloseKey(regKey);
       }
    
       // we need to tell WinCE we started properly
       SignalStarted(_ttoi(argv[1]));
    
       return 0;
    }
    

    “Launch18”和“Depend19”的值在您的平台上可能会有所不同。只需确保此程序在 device.exe 之前运行。

    注意:在许多平台上,该程序必须签名,并且您的证书需要安装在设备上。如果不是,则它不会运行。

    【讨论】:

      猜你喜欢
      • 2010-10-19
      • 1970-01-01
      • 2011-12-19
      • 1970-01-01
      • 2013-03-27
      • 2011-09-11
      • 2020-02-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多