Ver Mensaje Individual
  #1  
Antiguo 08-06-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
Listar las memorias usb conectadas

Esta funcion crea una lista con los dispositivos de almacenamiento USB conectados al equipo, en cada linea de la lista se puede leer la identificacion del vendedor, la del producto y el numero de serie (el grabado en fabrica)

Código Delphi [-]
uses Registry;

procedure ListarUSB(Lista: TStringList);
var
  i: integer;
begin
  with TRegistry.Create do
  try
    RootKey:= HKEY_LOCAL_MACHINE;
    if OpenKey('\SYSTEM\CurrentControlSet\Services\USBSTOR\Enum',FALSE) then
    begin
      i:= 0;
      while ValueExists(IntToStr(i)) do
      begin
        Lista.Add(ReadString(IntToStr(i)));
        inc(i);
      end;
      CloseKey;
    end;
  finally
    Free;
  end;
end;


Ejemplo de uso:
Código Delphi [-]
var
  Lista: TstringList;
  i: Integer;
begin
  Lista:= TStringList.Create;
  try
    ListarUSB(Lista);
    for i:= 0 to Lista.Count-1 do
      ShowMessage(Lista[ i ]);
  finally
    Lista.Free;
  end;
end;


Posibles usos, utilizar una meoria usb como llave hardware en uno de nuestros programas. Eso lo dejo para un truco diferente ...
Responder Con Cita