I have a printer connected with USB port and I want to get some information about it. I am using SetupDiEnumDeviceInfo
function from setupapi
to get information. I am doing everything as it is described in MSDN.
#include <string>
#include <windows.h>
#include <vector>
#include <iostream>
#include <setupapi.h>
#include <winerror.h>
#pragma comment (lib, "SetupAPI.lib")
static GUID GUID_DEVCLASS_PORTS = { 0x4d36e978, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18 };
int main()
{
SP_DEVINFO_DATA devInfoData;
HDEVINFO deviceInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_PORTS, 0, 0, DIGCF_PRESENT);
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
DWORD nDevice = 0;
if (SetupDiEnumDeviceInfo(deviceInfo, nDevice, &devInfoData))
{
}
return 0;
}
The problem is that I am always getting false
result.
GetLastError()
function retruns 259.
What am I doing wrong?