PDA

Ver la Versión Completa : Listar Memorias USB en windows 8


jandro
22-04-2013, 16:25:58
Hola a todos!

Acabo de comprar un portátil y al instalarle mi programa la protección que tenía con uno de los trucos del foro para listar las memorias USB conectadas no funciona.

Este es el codigo:

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;


Alguien sabe porque puede ser??? En windows 7 funciona y en windows 8 no. He revisado que la ruta de la Key sea la misma y si que lo es.

Espero me puedan ayudar!
Gracias.
Jandro.

WkaymQ48
22-04-2013, 17:26:08
Cambia esta linea:

if OpenKey('\SYSTEM\CurrentControlSet\Services\USBSTOR\Enum',FALSE) then


Por esta otra:

if OpenKeyReadOnly('\SYSTEM\CurrentControlSet\Services\USBSTOR\Enum') then

jandro
22-04-2013, 18:08:44
Mil gracias de verdad!!

Saludos.