变态重口极致另类在线-波多久久夜色精品国产-波多野结衣在线观看一区-波多野结衣在线观看一区二区-污污的网站免费阅读-污污视频网址

當前位置:首頁文章首頁 IT學院 IT技術

全自動安裝卸載驅動程序的源程序

作者:  來源:  發(fā)布時間:2011-12-15 0:53:30  點擊:
   {

   return DisplayError(TEXT(CreateDeviceInfoList));

   }

   //

   // Now create the element.

   // Use the Class GUID and Name from the INF file.

   //

   DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);

   if (!SetupDiCreateDeviceInfo(DeviceInfoSet,

   ClassName,

   &ClassGUID,

   NULL,

   0,

   DICD_GENERATE_ID,

   &DeviceInfoData))

   {

   DisplayError(TEXT(CreateDeviceInfo));

   goto cleanup_DeviceInfo;

   }

   //

   // Add the HardwareID to the Device's HardwareID property.

   //

   if(!SetupDiSetDeviceRegistryProperty(DeviceInfoSet,

   &DeviceInfoData,

   SPDRP_HARDWAREID,

   (LPBYTE)HardwareId,

   (lstrlen(HardwareId)+1+1)*sizeof(TCHAR)))

   {

   DisplayError(TEXT(SetDeviceRegistryProperty));

   goto cleanup_DeviceInfo;

   }

   //

   // Transform the registry element into an actual devnode

   // in the PnP HW tree.

   //

   if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE,

   DeviceInfoSet,

   &DeviceInfoData))

   {

   DisplayError(TEXT(CallClassInstaller(REGISTERDEVICE)));

   goto cleanup_DeviceInfo;

   }

   //

   // The element is now registered. We must explicitly remove the

   // device using DIF_REMOVE, if we encounter any failure from now on.

   //

   //

   // Install the Driver.

   //

   if (!UpdateDriverForPlugAndPlayDevices(0,

   HardwareId,

   INFFile,

   INSTALLFLAG_FORCE,

   RebootRequired))

   {

   DWORD err = GetLastError();

   DisplayError(TEXT(UpdateDriverForPlugAndPlayDevices));

   if (!SetupDiCallClassInstaller(

   DIF_REMOVE,

   DeviceInfoSet,

   &DeviceInfoData))

   {

   DisplayError(TEXT(CallClassInstaller(REMOVE)));

   }

   SetLastError(err);

   }

   //

   // Cleanup.

   //

  cleanup_DeviceInfo:

   err = GetLastError();

   SetupDiDestroyDeviceInfoList(DeviceInfoSet);

   SetLastError(err);

   return err == NO_ERROR;

  }

  int InstallDriver(_TCHAR *InfName, _TCHAR *HardwareID)

  {

   WIN32_FIND_DATA FindFileData;

   BOOL RebootRequired = 0; // Must be cleared.

   _TCHAR *FName, *HWID;

   FName = InfName;

   HWID = HardwareID;

   if (FindFirstFile(FName,&FindFileData)==INVALID_HANDLE_VALUE)

   {

   //_tprintf(TEXT( File not found.\\n));

   //_tprintf(TEXT(usage: install \\n));

   return 2; // Install Failure

   }

   //

   // Look to see if this device allready exists.

   //

   if (FindExistingDevice(HWID))

   {

   //

   // No Need to Create a Device Node, just call our API.

   //

   if (!UpdateDriverForPlugAndPlayDevices(0, // No Window Handle

   HWID, // Hardware ID

   FName, // FileName

   INSTALLFLAG_FORCE,

   &RebootRequired))

   {

   DisplayError(TEXT(UpdateDriverForPlugAndPlayDevices));

   return 2; // Install Failure

   }

   }

   else

   {

   if (GetLastError()!= ERROR_NO_MORE_ITEMS)

   {

   //

   // An unknown failure from FindExistingDevice()

   //

   //_tprintf(TEXT((IERROR_NO_MORE_ITEMS)\\n));

   //_tprintf(TEXT((Install Failure! Code = 2)\\n));

   return 2; // Install Failure

   }

   //

   // Driver Does not exist, Create and call the API.

   // HardwareID must be a multi-sz string, which argv[2] is.

   //

   if (!InstallRootEnumeratedDriver(HWID, // HardwareID

   FName, // FileName

   &RebootRequired))

   {

   //_tprintf(TEXT((InstallRootEnumeratedDriver Failure! Code = 2)\\n

  ));

   return 2; // Install Failure

   }

   }

   //_tprintf(TEXT(Driver Installed successfully.\\n));

   if (RebootRequired)

   {

   //_tprintf(TEXT((Reboot Required)\\n));

   return 1; // Install Success, reboot required.

   }

   return 0; // Install Success, no reboot required.

  }

  int RemoveDriver(_TCHAR *HardwareID)

  {

   HDEVINFO DeviceInfoSet;

   SP_DEVINFO_DATA DeviceInfoData;

   DWORD i,err;

   DeviceInfoSet = SetupDiGetClassDevs(NULL, // All Classes

   0,

   0,

   DIGCF_ALLCLASSES | DIGCF_PRESENT ); // All devices present on system

   if (DeviceInfoSet == INVALID_HANDLE_VALUE)

   {

   DisplayError(TEXT(GetClassDevs(All Present Devices)));

   return 1;

   }

   //

   // Enumerate through all Devices.

   //

   DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);

   for (i=0;SetupDiEnumDeviceInfo(DeviceInfoSet,i,&DeviceInfoData);i++)

首頁 上一頁 [1] [2] [3]  下一頁 尾頁
上一篇:USB 驅動自動卸載方法 下一篇:

文章評論

軟件按字母排列: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
主站蜘蛛池模板: 免费高清a级毛片在线播放 免费高清欧美一区二区视频 | 一级a毛片免费观看久久精品 | 国产成人午夜精品影院游乐网 | 激情五月激情综合色区 | 久久夜视频 | 日本一区二区三区免费观看 | 在线黄站 | 欧美日韩一区在线观看 | 伊人色综合琪琪久久社区 | 人与禽的免费一级毛片 | 兔费看全黄三级 | np饥渴放荡总受高hbl皇帝攻 | 欧美特黄一级视频 | 久久精品国产999久久久 | 一个人看的www日本高清视频 | 国产午夜久久精品 | 视频二区欧美 | 欧美日韩久久中文字幕 | a级毛片蜜桃成熟时2在线播放 | 日韩福利在线观看 | 中文字幕亚洲天堂 | free性欧美淫俄罗斯 | 亚洲综合激情 | 国产成人免费永久播放视频平台 | 男人边吃奶边爱边做视频刺激 | 曰曰碰天天碰国产 | 最新黄色网址在线观看 | 九九久久国产精品 | 黄色网 在线播放 | 男女无遮挡在线完整视频 | 一区二区三区福利视频 | 一级特黄录像免费播放中文版 | 91久久线看在观草草青青 | 最近2019中文免费字幕 | 国产成a人片在线观看视频99 | 一级女性全黄生活片免费 | 欧美视频一区 | 国产精品每日更新在线观看 | 丁香欧美| 免费人成在线观看网站视频 | 天天澡天天摸天天爽免费 |