function getDevice:
string;
const
Anschlguid = '
{4D36E978-E325-11CE-BFC1-08002BE10318}';
var
GUID: PGUID;
Buffer:
array[0..1023]
of TCHAR;
NameBuffer:
array[0..1023]
of Char;
Descriptionstr:
string;
PnPHandle: HDEVINFO;
DevData: TSPDevInfoData;
DeviceInterfaceData: TSPDeviceInterfaceData;
Success: LongBool;
BufSize: DWORD;
Devn: Integer;
S:
string;
aguid: Tguid;
begin
LoadSetupApi;
LoadConfigManagerApi;
GetMem(
GUID, SizeOf(TGUID));
guid^ := StringToGUID(Anschlguid);
SetupDiGetClassDescription(
GUID^, @Buffer[0], Length(Buffer), BufSize);
Descriptionstr := PTSTR(@Buffer[0]);
aguid :=
Guid^;
PnPHandle := SetupDiGetClassDevs(@AGUID,
nil, 0, DIGCF_PRESENT);
//PnPHandle := SetupDiGetClassDevs(@AGUID, nil, 0, 0);
if PnPHandle = Pointer(INVALID_HANDLE_VALUE)
then
begin
FreeMem(
GUID);
Result := '
';
Exit;
end;
Devn := 0;
repeat
DeviceInterfaceData.cbSize := SizeOf(TSPDeviceInterfaceData);
DevData.cbSize := SizeOf(DevData);
Success := SetupDiEnumDeviceInfo(PnPHandle, Devn, DevData);
if Success
then
begin
S := GetRegistryPropertyString(PnPHandle, DevData, SPDRP_FRIENDLYNAME);
if S = '
'
then
S := GetRegistryPropertyString(PnPHandle, DevData, SPDRP_DEVICEDESC);
if Pos(UMtsappli, s) > 0
then
begin
Result := StrBetween(s, '
(', '
)');
end;
Inc(Devn);
end;
until not Success;
SetupDiDestroyDeviceInfoList(PnPHandle);
UnloadConfigManagerApi;
UnloadSetupApi;
end;