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

當前位置:首頁文章首頁 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
主站蜘蛛池模板: 99视频精品全国在线观看 | 国产成人免费网站在线观看 | 亚洲欧洲国产精品你懂的 | 欧美日韩国产在线一区 | 91桃色视频在线观看 | 欧美三页| 好男人在线社区影院www | 免费一区二区三区在线视频 | 欧美成人se01短视频在线看 | 国产成人高清精品免费观看 | 日韩中文字幕在线亚洲一区 | aaa在线观看视频高清视频 | 免费的黄色小视频 | 天天做天天爱夜夜爽女人爽宅 | 五月天堂网| 九九九九精品视频在线播放 | 色综合欧美 | 黄视频网站大全 | 国产精品偷伦视频播放 | 小明日韩在线看看永久区域 | 黄色小视频在线观看免费 | 男女视频免费观看 | 综合视频网 | 五月婷婷视频在线 | 福利片 在线 | 日本国产美国日韩欧美mv | 国产在线精品二区李沁 | 窝窝午夜一级看片爽 | 日本成年网 | 日韩欧美亚州 | 欧美激情一区二区三区在线 | 成人羞羞视频网站 | 亚洲欧美另类综合 | www.亚洲精品 | 色视频在线观看免费 | 欧美在线精品一区二区三区 | 国产综合免费视频 | 韩国午夜tv免费影院 | 在线亚洲+欧美+日本专区 | 久久精品国产欧美日韩亚洲 | 最近新中文字幕大全高清 |