在窗体上放一个edit,一个button,双击button,输入代码:
procedure TForm1.Button1Click(Sender: TObject);
var
reg:TRegistry;
a,i:word;
begin
edit1.Text:=lowercase(edit1.Text);
a:=0;
for i:=1 to length(edit1.text) do
a:=a or (1 shl (ord(edit1.text)-97));
reg:=TRegistry.Create;
try
reg.RootKey:=HKEY_CURRENT_USER;
if reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer',true) then begin
if reg.KeyExists('NoDrivers')=false
then reg.CreateKey('NoDrivers');
reg.WriteInteger('NoDrivers',a);
reg.CloseKey;
end;
finally
reg.Free;
inherited;
end;
end;
edit1是输入你要隐藏的字符串,比如你要隐藏D,E盘,就在edit1中输入de即可。