SetupDiGetDeviceProperty를 사용하려하지만 setupapi.h에서 이러한 기능을 찾을 수 없습니다. 나는 문서를보고 모든 헤더와 라이브러리 파일을 포함 시켰지만, 단지 함수를 사용하도록 내버려 두지 않고있다. 어떻게 될 것인가? 내가 잘못하고 있는게 뭐지? Heres는 코드 다음 SetupDiGetDeviceProperty 기능이 ListAllDevices 함수의 맨 아래라고SetupDiGetDeviceProperty 기능이 작동하지 않는 이유는 무엇입니까?
//Mainframe.cpp file
#include"DeviceManager.h"
int main()
{
int iQuit;
DeviceManager deviceManager;
deviceManager.ListAllDevices();
std::cin >> iQuit;
return 0;
}
//DeviceManager.h file
#include <windows.h>
#include <setupapi.h>
#include <iostream>
#include <cfgmgr32.h>
#include <tchar.h>
#include <devpkey.h>
//#pragma comment (lib, "setupapi.lib")
class DeviceManager
{
public:
DeviceManager();
~DeviceManager();
void ListAllDevices();
};
//DeviceManager.cpp file
#include"DeviceManager.h"
DeviceManager::DeviceManager()
{
}
DeviceManager::~DeviceManager()
{
}
void DeviceManager::ListAllDevices()
{
HDEVINFO deviceInfoSet; //A list of all the devices
SP_DEVINFO_DATA deviceInfoData; //A device from deviceInfoSet
DEVPROPTYPE devicePropertyType;
//CONFIGRET device;
DWORD deviceIndex = 0;
DWORD size;
TCHAR description[1024];
bool foundAllDevices = false;
deviceInfoSet = SetupDiGetClassDevs(NULL, TEXT("USB"), NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES); //Gets all Devices
deviceInfoData.cbSize = sizeof(deviceInfoData);
while(SetupDiEnumDeviceInfo(deviceInfoSet, deviceIndex, &deviceInfoData))
{
deviceInfoData.cbSize = sizeof(deviceInfoData);
ULONG tcharSize;
CM_Get_Device_ID_Size(&tcharSize, deviceInfoData.DevInst, 0);
TCHAR* deviceIDbuffer = new TCHAR[tcharSize]; //the device ID will be stored in this array, so the tcharSize needs to be big enough to hold all the info.
//Or we can use MAX_DEVICE_ID_LEN, which is 200
CM_Get_Device_ID(deviceInfoData.DevInst, deviceIDbuffer, MAX_PATH, 0); //gets the devices ID - a long string that looks like a file path.
SetupDiGetDeviceProperty(deviceInfoSet, deviceInfoData, DEVPKEY_NAME, devicePropertyType, description, sizeof(description), size, 0);
std::cout << deviceIDbuffer << std::endl;
deviceIndex++;
}
}
.
감사
편집 : 인텔리 : 문서에 설명 된대로 식별자 "SetupDiGetDeviceProperty이"정의되지
IntelliSense 오류는 인용 할 수있는 가장 적합한 오류가 아닙니다. 나는 컴파일러가 내뿜는 에러를 인용 할 것이다. IntelliSense는 잘못 이해할 수 있습니다. –