在大家使用windows驱动与应用程序进行交互时,可能会用到常用的SetupApi,SetupApi被包含在#include <setupapi.h>头文件中,如果大家直接使用这个头文件的话,Visual Studio会报错很多错误。
因为setupapi.h依赖这些头文件
#include <windows.h> // Includes basic windows functionality.
#include <stdio.h> // Includes the standard i/o functions.
#include <string.h> // Includes the string functions.
#include <tchar.h> // Includes the string functions.
#include <setupapi.h> // Includes the SetupAPI.
另外还要调用setupapi.lib
// Link with SetupAPI.Lib.
#pragma comment (lib, "setupapi.lib")
然后就可以正常使用Setup API了。