procedure bloquearUSB;
var
reg : TRegistry;
begin
reg := TRegistry.create;
with reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('\SYSTEM\CurrentControlSet\Services\UsbStor', false) then
begin
//quatro bloqueia
reg.WriteInteger('Start', 4);
//caminho do arquivo que o windows usa para montar a unidade usb
reg.WriteString('ImagePath', '_system32\DRIVERS\USBSTOR.SYS');
end;
CloseKey;
end;
end;
Procedure desbloquearUSB;
var
reg : Tregistry;
begin
reg := TRegistry.Create;
with reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('\SYSTEM\CurrentControlSet\Services\UsbStor', false) then
begin
//tres desbloqueia
reg.WriteInteger('Start', 3);
//caminho do arquivo que o windows usa para montar a unidade usb
reg.WriteString('ImagePath', 'system32\DRIVERS\USBSTOR.SYS');
end;
end;
end;