You are on page 1of 1

using namespace std;

int main(int argc, char *argv[])


{
GUID GUID_INTERFACE_PCI_DEVICE = {0x4D36E97D, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08,0x00,0x2B,0xE1,0x03,0x18};
HDEVINFO hardwareDeviceInfo;
SP_DEVICE_INTERFACE_DATA deviceInfoData;
PUSB_DEVICE_DESCRIPTOR usbDeviceInst;
char *outNameBuf = new char[50];
char *NomeInterface = "PCI",*outString = "Xulambs";
char *inString = (char *)malloc(50);
PSP_DEVICE_INTERFACE_DETAIL_DATA functionClassDeviceData = NULL;
ULONG predictedLength = 0;
ULONG requiredLength = 0;
HANDLE hFile = INVALID_HANDLE_VALUE;

deviceInfoData.cbSize = sizeof (SP_DEVICE_INTERFACE_DATA);


hardwareDeviceInfo = SetupDiGetClassDevs (
&GUID_INTERFACE_PCI_DEVICE,
NULL, // Define enumerador global
NULL, // Define sem janela de usuário
(DIGCF_PRESENT | // Somente dispositivo presente
DIGCF_DEVICEINTERFACE)); // Apenas dispositivo descrito pelo GUID acima.
if (SetupDiEnumDeviceInterfaces (hardwareDeviceInfo,
0, // We don't care about specific PDOs
(LPGUID) &GUID_INTERFACE_PCI_DEVICE,
3,
&deviceInfoData)) {

if (! SetupDiGetDeviceInterfaceDetail (
hardwareDeviceInfo,
&deviceInfoData,
functionClassDeviceData,
predictedLength,
&requiredLength,
NULL)) {
free( functionClassDeviceData );
}
else{
hFile = CreateFile (
functionClassDeviceData->DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, // no SECURITY_ATTRIBUTES structure
OPEN_EXISTING, // No special create flags
0, // No special attributes
NULL); // No template file
if(hFile != INVALID_HANDLE_VALUE){
WriteFile(hFile,outString,7,NULL,NULL);
ReadFile(hFile,inString,10,NULL,NULL);
}
}

} else {
cout << GetLastError() << endl;
}

// SetupDiDestroyDeviceInfoList() destroi conjunto de informações sobre dispostivo


// e liberar toda memória reservada para o processo.

system("PAUSE");
SetupDiDestroyDeviceInfoList (hardwareDeviceInfo);
return EXIT_SUCCESS;
}

You might also like