VC Installation Driver detailed explanation

Source: Internet
Author: User
Tags error code
Recently wrote a product similar to Android Phone helper in C + +, one module function is to detect and monitor the device ID of the Android device, retrieve the driver and install it according to the device ID. So the search for a lot of information about the driver installation is now organized as follows:

Drivers are divided into WDM and NT-type drivers, and I understand the difference between the two:
1. WDM is loaded by the. inf file, and NT is manually loaded by the service
2. WDM supports Plug and Play, NT does not support Plug and Play
3. WDM specifies mount that driver through the registry, NT can specify mount by looking for different device objects
Further information:
Http://blog.sina.com.cn/s/blog_5371d2790100djku.html

There are two ways to install the drive (many ways):
1, when the device is plugged in to install, that is, using the function UPDATEDRIVERFORPLUGANDPL Aydevice (). That's the way I use it.
2, in the absence of physical equipment when installed, that is commonly referred to as the driver pre-installation (SetupCopyOEMInf).

Method 3
3. DefaultInstall method
Dos run rundll32.exe setupapi.dll,installhinfsection DefaultInstall Test.inf
Specifically, you can query MSDN, which is said to be detailed, but also refer to the following information:
Http://www.360doc.com/content/11/0912/14/2406028_147664842.shtml
Http://www.52rd.com/Blog/Detail_RD.Blog_xjl20008_8591.html

Method 4
4. drive files into the installation package, by the installation package to automate (this method I do not know more about)


It is important to note that:
1. SetupCopyOEMInf () just generates a Oem*.inf file and oem*.pnf file into the windows\inf\ folder, i.e. no registry is modified and no files are copied. The generated PNF file contains the source file path information so that the corresponding SYS files can be found when the device is actually plugged in. This is done by the device without inserting it. After the device is inserted, the system will pop the window to prompt the user whether to install the driver, the user chose to be after the device-driven installation

2. UPDATEDRIVERFORPLUGANDPL Aydevice () fails to execute when the device is not plugged in. This method is silent installation, that is, during the installation process, will not pop up any prompt window, after installation, we can see through Device Manager that the device is ready to use status.

UPDATEDRIVERFORPLUGANDPL Aydevice () mode Source:
Http://blog.sina.com.cn/s/blog_5d51f4e90101afg2.html
This source code is more general, is according to DDK below installation driver example source code. Of course, when we call the interface in this source code, it is best to confirm that the device ID to be installed exists in the. inf file, that is, this driver supports this device. This confirmation process needs to use the SETUPAPI series functions to obtain the device ID and. inf file parsing, this piece of online also has a lot of source code, if there is a need source code can contact me: QQ 24716177


Precautions:
As we all know, the Windows program is mainly divided into 32-bit and 64-bit (can be set in the compiler), for 64-bit PC, must use 64-bit program to install, of course, 32-bit machine must use 32-bit program to install, otherwise it will fail to install.
For example, when installing with UPDATEDRIVERFORPLUGANDPL Aydevice, a very large negative number is returned-87554 ...
And the error code is not obtained with GetLastError (). Before a Web site to see a foreigner tangled this problem for a long time, and finally unexpectedly said it seems because the INF file format is not correct, it seems that foreigners have such a stupid technical staff.

If we do not know how many bits of the user's PC, we should do 64-bit and 32-bit two version of the driver installation program, before invoking the installation program, determine the current system's number of bits, and then enable the corresponding number of bits of the installation program.

The above precautions, we must pay attention to ...

Reference information:
http://bbs.csdn.net/topics/320020273
http://bbs.csdn.net/topics/190082352
http://bbs.csdn.net/topics/60192108
http://bbs.csdn.net/topics/60192108
http://bbs.csdn.net/topics/390372266
http://bbs.csdn.net/topics/330055489
Http://blog.sina.com.cn/s/blog_5371d2790100djku.html
Http://hi.baidu.com/alalmn/item/752818ab8caa2ba928ce9d76
Http://www.52rd.com/Blog/Detail_RD.Blog_xjl20008_8591.html
Http://www.360doc.com/content/11/0912/14/2406028_147664842.shtml

SETUPAPI Series Functions Daquan:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff549791 (v=vs.85). aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.