怎样得到U盘的出厂物理编号????????
解决方案 »
- RichEdit 字体 问题
- 为什么我的D7中InternetExpress组件面板中找不到TMidasPageProducer控件,D7都重装了N遍了还是这样
- 急问,如何把qry查询出来的数据做个自动转换??应该不难
- 有什么工具可以在一个项目中寻找含指定字符串的.PAS文件?
- Monks, 進來拿分吧﹗
- delphi7中函数arctan怎样编写
- 为什么我作的报表在行式打印机上不能正常打印
- 大虾帮帮忙,一个关于bpl的问题,十万火急!能给的分我都拿出来了
- 给分的问题
- 谁能描绘下ScanLine的用法?
- 捞分的机会来了 如何做才能在点击dbgrid的VSscrollbar时,记录集位置不变????
- StringGrid如何控制某几列数据不允许修改
http://www.wbj3000.com/
网站上去下载【U盘检测器 v5.0】
它可以给你给出相应的数据!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;{
typedef struct _USB_DEVICE_DESCRIPTOR {
UCHAR bLength ;
UCHAR bDescriptorType ;
USHORT bcdUSB ;
UCHAR bDeviceClass ;
UCHAR bDeviceSubClass ;
UCHAR bDeviceProtocol ;
UCHAR bMaxPacketSize0 ;
USHORT idVendor ;
USHORT idProduct ;
USHORT bcdDevice ;
UCHAR iManufacturer ;
UCHAR iProduct ;
UCHAR iSerialNumber ;
UCHAR bNumConfigurations ;
}
const
DIGCF_PRESENT = 2;
DIGCF_INTERFACEDEVICE = 16;
type PSP_DEVINFO_DATA = ^SP_DEVINFO_DATA;
SP_DEVINFO_DATA = packed record
cbSize :DWORD;
ClassGuid :TGUID;
DevInst :DWORD ; // DEVINST handle
Reserved :DWORD;
end; HDEVINFO = Pointer; pulong = ^ulong; PSP_INTERFACE_DEVICE_DATA = ^SP_INTERFACE_DEVICE_DATA;
SP_INTERFACE_DEVICE_DATA = packed record
cbSize :ulong;
InterfaceClassGuid : TGuid;
Flags :ulong;
Reserved :ulong;
end; PSP_INTERFACE_DEVICE_DETAIL_DATA = ^PSP_INTERFACE_DEVICE_DETAIL_DATA;
SP_DEVICE_INTERFACE_DETAIL_DATA = packed record
cbSize :DWORD;
DevicePath: Char;
end;
PUSB_DEVICE_DESCRIPTOR = ^USB_DEVICE_DESCRIPTOR;
USB_DEVICE_DESCRIPTOR = packed record
bLength :UCHAR;
bDescriptorType :UCHAR;
bcdUSB :WORD;
bDeviceClass :UCHAR;
bDeviceSubClass :UCHAR;
bDeviceProtocol :UCHAR;
bMaxPacketSize0 :UCHAR;
idVendor :Word;
idProduct :Word;
bcdDevice :Word;
iManufacturer :UCHAR;
iProduct :UCHAR;
iSerialNumber :UCHAR;
bNumConfigurations :UCHAR;
end;function SetupDiGetDeviceInterfaceDetail(
DeviceInfoSet : HDEVINFO;
DeviceInterfaceData: PSP_INTERFACE_DEVICE_DATA;
DeviceInterfaceDetailData: PSP_INTERFACE_DEVICE_DETAIL_DATA;
DeviceInterfaceDetailDataSize : DWORD;
RequiredSize : PDWORD;
DeviceInfoData : PSP_DEVINFO_DATA
): BOOL; stdcall; external 'SETUPAPI.dll' name 'SetupDiGetDeviceInterfaceDetailA';function SetupDiGetClassDevsEx(
ClassGuid :PGUID;
Enumerator :PChar;
hwndParent :HWND;
Flags : DWORD;
MachineName :PChar;
Reserved :Pointer
): HDEVINFO; stdcall; external 'SETUPAPI.dll' name 'SetupDiGetClassDevsExA';function SetupDiGetClassDevs(
ClassGuid :PGUID ;
Enumerator: PChar;
hwndParent: HWND;
Flags : DWORD
): HDEVINFO; stdcall; external 'SETUPAPI.dll' name 'SetupDiGetClassDevsA';function SetupDiEnumDeviceInterfaces(
DeviceInfoSet :HDEVINFO;
DeviceInfoData :PSP_DEVINFO_DATA;
InterfaceClassGuid :PGUID;
MemberIndex :DWORD;
DeviceInterfaceData :PSP_INTERFACE_DEVICE_DATA
): BOOL; stdcall; external 'SETUPAPI.dll' name 'SetupDiEnumDeviceInterfaces';function SetupDiDestroyDeviceInfoList(
DeviceInfoSet :HDEVINFO
):BOOL; stdcall; external 'SETUPAPI.dll' name 'SetupDiEnumDeviceInterfaces';type
TOnGetStrEvent = procedure(AStr :string) of object;//以下代码可枚举所有设备const //USBIODS_GUID : TGuid = '{745a17a0-74d3-11d0-b6fe-00a0c90f57da}';
USBIODS_GUID : TGuid = '{a5dcbf10-6530-11d2-901f-00c04fb951ed}';type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var b :integer;
bRst :BOOL;
hInfo :HDEVINFO;
// USBIODS_GUID :TGuid;
deviceInterfaceData :SP_INTERFACE_DEVICE_DATA;
DeviceDetailData :SP_DEVICE_INTERFACE_DETAIL_DATA; predictedLength : ULONG;
requiredLength :ULONG;
nCount: integer;
begin
Memo1.Clear;{ USBIODS_GUID.D1 := $a5dcbf10;
USBIODS_GUID.D2 := $6530;
USBIODS_GUID.D3 := $11d2;
USBIODS_GUID.D4[0] := $90;
USBIODS_GUID.D4[1] := $1f;
USBIODS_GUID.D4[2] := $00;
USBIODS_GUID.D4[3] := $c0;
USBIODS_GUID.D4[4] := $4f;
USBIODS_GUID.D4[5] := $b9;
USBIODS_GUID.D4[6] := $51;
USBIODS_GUID.D4[7] := $ed;
}
// USBIODS_GUID := '{a5dcbf10-6530-11d2-901f-00c04fb951ed}'; predictedLength := 0;
requiredLength := 0;
hInfo := nil;
hInfo := SetupDiGetClassDevs(@USBIODS_GUID, nil, 0,
DIGCF_PRESENT OR DIGCF_INTERFACEDEVICE); bRst := true;
nCount := 0; deviceInterfaceData.cbSize := Sizeof(SP_INTERFACE_DEVICE_DATA);
DeviceDetailData.cbSize := sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); if hInfo = nil then
begin
showmessage('failed 0');
exit;
end; while bRst do
begin
deviceInterfaceData.cbSize := Sizeof(deviceInterfaceData); bRst := SetupDiEnumDeviceInterfaces(hInfo, nil, @USBIODS_GUID,
nCount, @deviceInterfaceData); if bRst then
begin
SetupDiGetDeviceInterfaceDetail(hInfo, @deviceInterfaceData,
nil, 0, @requiredLength, nil);
predictedLength := requiredLength;
DeviceDetailData.cbSize := sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
bRst := SetupDiGetDeviceInterfaceDetail(hInfo, @deviceInterfaceData,
@DeviceDetailData, predictedLength, @requiredLength, nil); if bRst then
begin
// showmessage('ok'+inttostr(nCount));
///// pszDevicePath[nCount] := string(PChar(@(DeviceDetailData.DevicePath)));
showmessage(string(PChar(@(DeviceDetailData.DevicePath))));
//// Memo1.Lines.Add(pszDevicePath[nCount]);
// Memo1.Lines.Add(string(PChar(@(DeviceDetailData.DevicePath))));
Inc(nCount);
end;
end;
end; //end while
showmessage('finished');
// SetupDiDestroyDeviceInfoList(hInfo);
end;
end.
注册表就有的
SetupAPI获得的数据同注册表的一样的_____________________
http://lysoft.7u7.net