1. Я доработал чуток схему, чтобы можно получить информацию обо всех подключенных устройств такого типа, в делфи я не шарю, чисто опираясь на язык С/С++.
Add(MainForm,13673400,175,182)
{
Width=300
Height=200
link(onCreate,12929181:doCheck,[])
}
Add(InlineCode,12929181,245,196)
{
WorkPoints=#7:doCheck|
EventPoints=#7:onCheck|
DataPoints=#7:VID_PID|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|38:uses kol,Windows,Share,Debug,Messages;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|11:VP: String;|0:|9: public|0:|26:onCheck,VID_PID:THI_Event;|48:Procedure doCheck (var _Data:TData; Index:word);|0:|5: end;|0:|5:const|36: DIGCF_PRESENT = $00000002;|36: DIGCF_ALLCLASSES = $00000004;|2: |36: SPDRP_DEVICEDESC = $00000000;|36: SPDRP_HARDWAREID = $00000001;|36: SPDRP_FRIENDLYNAME = $0000000C;|36: SPDRP_LOCATION_INFO = $0000000D;|0:|4:type|25: TSPDevInfoData = record|18: cbSize: DWORD;|21: ClassGuid: TGUID;|19: DevInst: DWORD;|24: Reserved: LongWord; |6: end;|0:|169:function SetupDiGetClassDevs(ClassGuid: PGUID; Enumerator: PChar; hwndParent: HWND; Flags: DWORD): THandle; stdcall; external 'setupapi.dll' name 'SetupDiGetClassDevsA';|180:function SetupDiEnumDeviceInfo(DeviceInfoSet: THandle; MemberIndex: DWORD; var DeviceInfoData: TSPDevInfoData): BOOL; stdcall; external 'setupapi.dll' name 'SetupDiEnumDeviceInfo';|247:function SetupDiGetDeviceInstanceId(DeviceInfoSet: THandle; var DeviceInfoData: TSPDevInfoData; DeviceInstanceId: PChar; DeviceInstanceIdSize: DWORD; RequiredSize: PDWORD): BOOL; stdcall; external 'setupapi.dll' name 'SetupDiGetDeviceInstanceIdA';|302:function SetupDiGetDeviceRegistryProperty(DeviceInfoSet: THandle; var DeviceInfoData: TSPDevInfoData; Property_: DWORD; PropertyRegDataType: PDWORD; PropertyBuffer: PByte; PropertyBufferSize: DWORD; RequiredSize: PDWORD): BOOL; stdcall; external 'setupapi.dll' name 'SetupDiGetDeviceRegistryPropertyA';|138:function SetupDiDestroyDeviceInfoList(DeviceInfoSet: THandle): BOOL; stdcall; external 'setupapi.dll' name 'SetupDiDestroyDeviceInfoList';|0:|0:|0:|14:implementation|0:|61:Procedure THiAsmClass.doCheck (var _Data:TData; Index:word);|3:var|22: DevInfoSet: THandle;|30: DevInfoData: TSPDevInfoData;|13: i: Integer;|33: Buffer: array[0..1024] of Char;|37: S_InstId, S_Target,NameStr: String;|2: |45: function TryGetProp(PropID: DWORD): String;|7: begin|40: FillChar(Buffer, SizeOf(Buffer), 0);|119: if SetupDiGetDeviceRegistryProperty(DevInfoSet, DevInfoData, PropID, nil, PByte(@Buffer), SizeOf(Buffer), nil) then|30: Result := String(Buffer)|8: else|19: Result := '';|6: end;|0:|5:begin|16: NameStr := '';|40: S_Target := ReadString(_Data,VID_PID);|40: //S_Target := 'USB\VID_1A86&PID_7523';|2: |84: DevInfoSet := SetupDiGetClassDevs(nil, nil, 0, DIGCF_PRESENT or DIGCF_ALLCLASSES);|49: if DevInfoSet = INVALID_HANDLE_VALUE then Exit;|0:|27: DevInfoData.cbSize := 28;|9: i := 0;|2: |60: while SetupDiEnumDeviceInfo(DevInfoSet, i, DevInfoData) do|7: begin|44:// _hi_OnEvent (onCheck,i); //idx|40: FillChar(Buffer, SizeOf(Buffer), 0);|92: if SetupDiGetDeviceInstanceId(DevInfoSet, DevInfoData, Buffer, SizeOf(Buffer), nil) then|9: begin|44: S_InstId := UpperCase(String(Buffer));|5: |41: if Pos(S_Target, S_InstId) > 0 then|11: begin|50: NameStr := TryGetProp(SPDRP_FRIENDLYNAME);|69: if NameStr = '' then NameStr := TryGetProp(SPDRP_DEVICEDESC);|69: if NameStr = '' then NameStr := TryGetProp(SPDRP_HARDWAREID);|49: if NameStr = '' then NameStr := S_InstId;|32: _hi_OnEvent (onCheck,NameStr) |16:// Break;|10: end;|8: end;|11: Inc(i);|6: end;|4:end;|0:|4:end.|
link(onCheck,13756087:doAdd,[])
link(VID_PID,16453930:Text,[(251,146)(195,146)])
}
Add(Memo,13756087,336,196)
{
Left=75
Top=45
Width=280
Height=200
Align=5
Font=[Lucida Console,12,0,0,204]
Antialiased=1
ScrollBars=3
}
Add(VisualStrings,12293096,266,140)
{
Lines=#21:USB\VID_1A86&PID_7523|
Width=144
}
Add(VisualStrings,3173068,245,105)
{
Lines=#21:USB\VID_0483&PID_5740|
Width=151
}
Add(VisualStrings,16453930,189,77)
{
Lines=#7:USB\VID|
Width=151
}



Поиск
Друзья
Администрация