91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3.71 KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-08-12
  • 語言: 其他
  • 標簽: USB??

資源簡介

c++ 實現枚舉USB設備接口
涉及函數:
SetupDiGetClassDevs
SetupDiEnumDeviceInterfaces
SetupDiGetDeviceInterfaceDetail

資源截圖

代碼片段和文件信息

//?EnumDevice.cpp?:?Defines?the?entry?point?for?the?console?application.
//

#include?“stdafx.h“
#include??
#include?
#include?
#include?
#include?

using?namespace?std;

//U盤?interface?class?GUID?
GUID?IID_CLASS_WCEUSBS?={0xa5dcbf10?0x6530?0x11d2?0x90?0x1f?0x00?0xc0?0x4f?0xb9?0x51?0xed};

BOOL?SearchDevice(vector?&vDevicePath)
{
BOOL?bRes?=?FALSE;
LPGUID?pInterfaceGuid?=?&IID_CLASS_WCEUSBS;

HDEVINFO?hDeviceInfo?=?SetupDiGetClassDevs(?pInterfaceGuid
NULL
NULL
DIGCF_PRESENT?|?DIGCF_DEVICEINTERFACE);

if?(INVALID_HANDLE_VALUE?==?hDeviceInfo)
{
goto?Exit;
}

//?enum?device?interface
SP_DEVICE_INTERFACE_DATA?spDevInterData; //a?structure?of?device?interface?data

memset(&spDevInterData?0x00?sizeof(SP_DEVICE_INTERFACE_DATA));
spDevInterData.cbSize?=?sizeof(SP_DEVICE_INTERFACE_DATA);

DWORD?dwIndex?=?0;

while?(TRUE)
{
if?(!SetupDiEnumDeviceInterfaces(?hDeviceInfo
NULL
pInterfaceGuid
dwIndex
&spDevInterData))

{
if?(ERROR_NO_MORE_ITEMS?==?GetLastError())
{
OutputDebugStringW(L“No?more?interface“);
}
else
{
OutputDebugStringW(L“SetupDiEnumDeviceInterfaces?Error“);
}

goto?Exit;
}

//?get?length?of?interface?detail?info
DWORD?dwRequiredLength?=?0; //for?getting?length?of?inter?face?detail?data

if?(!SetupDiGetDeviceInterfaceDetail(?hDeviceInfo
&spDevInterData
NULL?
0
&dwRequiredLength
NULL))
{
if?(ERROR_INSUFFICIENT_BUFFER?!=?GetLastError())
{
OutputDebugStringW(L“calculate?require?length“);
//goto?Exit;
}
}

//?get?interface?detail?info
PSP_DEVICE_INTERFACE_DETAIL_DATA?pSpDIDetailData; //a?pointer?to?interface?detail?data

pSpDIDetailData?=?NULL;
pSpDIDetailData?=?(PSP_DEVICE_INTERFACE_DETAIL_DATA)HeapAlloc(GetProcessHeap()?HEAP_ZERO_MEMORY?dwRequiredLength);

if(NULL?==?pSpDIDetailData)
{
OutputDebugStringW(L“HeapAlloc?Memory?Failed“);

if?(!SetupDiDestroyDeviceInfoList(hDeviceInfo))
{
OutputDebugStringW(L“SetupDiDestroyDeviceInfoList?Error“);
}

goto?Exit;
}

pSpDIDetailData->cbSize?=?sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);

if?(!SetupDiGetDeviceInterfaceDetail(?hDeviceInfo
&spDevInterData
pSpDIDetailData
dwRequiredLength
&dwRequiredLength
NULL))
{
OutputDebugStringW(L“SetupDiGetDeviceInterfaceDetail?Error“);
goto?Exit;
}

wstring?wcsDevicePath?=?pSpDIDetailData->DevicePath;

vDevicePath.push_back(wcsDevicePath);?

if?(NULL?!=?pSpDIDetailData)
{
HeapFree(GetProcessHeap()?0?pSpDIDetailData);
pSpDIDetailData?=?NULL;
}

dwIndex++;
}

if?(!SetupDiDestroyDeviceInfoList(hDeviceInfo))
{
OutputDebugStringW(L“SetupDiDestroyDeviceInfoList?Error“);
}

bRes?=?TRUE;

Exit:
return?bRes;
}



int?_tmain(int?argc?_TCHAR*?argv[])
{

vector

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3241??2008-11-12?15:06??EnumDevice\EnumDevice\EnumDevice.cpp

?????文件???????4597??2008-11-05?19:39??EnumDevice\EnumDevice\EnumDevice.vcproj

?????文件????????297??2008-11-05?19:30??EnumDevice\EnumDevice\stdafx.cpp

?????文件????????516??2008-11-05?19:30??EnumDevice\EnumDevice\stdafx.h

?????文件????????895??2008-11-05?19:30??EnumDevice\EnumDevice.sln

?????目錄??????????0??2008-11-12?15:07??EnumDevice\EnumDevice

?????目錄??????????0??2008-11-12?15:07??EnumDevice

-----------?---------??----------?-----??----

?????????????????9546????????????????????7


評論

共有 條評論