Показать сообщение отдельно
  #4  
Старый 09.09.2023, 12:22
infopol infopol вне форума
Прохожий
 
Регистрация: 03.06.2021
Сообщения: 35
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию В процедуре ошибка

Код:
Type
  THIDUSBDeviceInfo = Record   { contains interface level information of each device}
    SymLink            : String;
    BufferSize         : Word;
    Handle             : THandle;
    VID                : DWord;
    PID                : DWord;
    VersionNumber      : Word;
    ManufacturerString : String;
    ProductString      : String;
    SerialNumberString : String;
  end;
  THIDDeviceList = Array of THIDUSBDeviceInfo;

Const
  HIDUSB_COUNTOFINTERRUPTBUFFERS = 64;   // Count of buffers for interrupt data


procedure EnumDevices( List:TStrings);
var
  DevInfo:HDEVINFO;
  InfoData:SP_DEVINFO_DATA;
  I,A,Size,DType:DWORD;
  Buffer,PC:PChar;
  GUID:TGUID;
begin
  I:=0;
  while True do begin
    if CM_Enumerate_Classes(I,GUID,0)=CR_NO_SUCH_VALUE then Break;
    DevInfo:=SetupDiGetClassDevs(@GUID,nil,0,DIGCF_PRESENT);
    if DevInfo<>HDEVINFO(INVALID_HANDLE_VALUE) then try
      InfoData.cbSize:=SizeOf(InfoData);
      A:=0;
      Buffer:=nil;
      try
        while SetupDiEnumDeviceInfo(DevInfo,A,InfoData) do begin
          Size:=0;
          while not SetupDiGetDeviceRegistryProperty(DevInfo,InfoData,SPDRP_HARDWAREID,DType,Pointer(Buffer),Size,Size) do
            if GetLastError=ERROR_INSUFFICIENT_BUFFER then
              ReallocMem(Buffer,Size)
            else
              Exit;
          PC:=Buffer;
          while PC^<>#0 do begin
            List.Add(PC);
            PC:=StrEnd(PC)+1;
          end;
          Inc(A);
        end;
      finally
        FreeMem(Buffer);
      end;
    finally
      SetupDiDestroyDeviceInfoList(DevInfo);
    end;
    Inc(I);
  end;
end;
if CM_Enumerate_Classes(I,GUID,0)=CR_NO_SUCH_VALUE then Break;
undeclare identifier
Ответить с цитированием