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

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

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

作者:  來源:  發布時間: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
主站蜘蛛池模板: 美女下面粉嫩粉嫩冒白浆高清 | 国产成人精品久久免费动漫 | 欧美福利影院 | 中文字幕亚洲国产 | 欧美日韩亚洲精品国产色 | 717影院理伦午夜论八戒 | 免费韩国伦理片 | 谁有免费黄色网址 | 国产一级片观看 | 国产成年网站 | 国产一级黄色大片 | 老色批在线播放视频网站免费 | 色视频线观看在线播放 | 欧美天堂在线观看 | 91在线精品亚洲一区二区 | 亚洲日本va中文字幕在线不卡 | 欧美日韩伦理 | 免费a级片在线观看 | 亚洲日本精品va中文字幕 | 欧美性f| 亚洲欧美卡通成人制服动漫 | 国产自在线拍 | 黄色在线观看视频网站 | 日韩视频第二页 | 免费h黄肉动漫在线观看 | 精品国产欧美另类一区 | 日韩福利视频高清免费看 | 精品视频专区 | 成人午夜毛片 | 日本久久香蕉一本一道 | 国产福利影院 | 欧美日韩视频在线第一区 | 未满十八18勿进黄网站免费看 | 免费网站看v片在线成人国产系列 | 最近更新中文字幕第一页 | 黄视频在线免费 | 国产欧美日韩另类一区乌克兰 | 欧美videos另类极品 | 一本大道久东京 | 中文字幕在线乱人伦 | dy888午夜国产午夜精品 |