Mira ya he creado la función que se supone me recoja la lista de dispositivos del sistema, me quedó así:
Código Delphi
[-]var
Form1: TForm1;
DeviceInfoSet : HDEVINFO;
NewDeviceInfoSet : HDEVINFO;
Código Delphi
[-]function CrearLista : Pointer;
begin
DeviceInfoSet := SetupDiCreateDeviceInfoList(NiL, HWND_TOP);
if (DeviceInfoSet = Pointer(INVALID_HANDLE_VALUE)) then
begin
ShowMessage('CreateDeviceInfoList failed: '+Inttostr(GetLastError()));
Result:=0;
Exit;
end;
NewDeviceInfoSet := SetupDiGetClassDevsEx(nil,Nil,HWND_DESKTOP,DIGCF_PRESENT or DIGCF_ALLCLASSES,DeviceInfoSet,NiL,NiL);
if (NewDeviceInfoSet = Pointer(Invalid_handle_value)) then
begin
ShowMessage('SetupDiGetClassDevsEx failed: '+inttostr(GetLastError));
Result:=0;
Exit;
end;
Result:=NewDeviceInfoSet;
end;
Para llamarla me dice que debo esperar al evento
DBT_DEVICEARRIVAL
algo nuevo para mi, una funcion con eventos?