Registry.RootKey:=HKEY_LOCAL_MACHINE;//打开注册表中HKEY_CLASSES_ROOT根键 //1.获取网卡GUI---------- for i:=1 to 10 do begin Registry.CloseKey; if Registry.OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\'+IntToStr(i),False) then begin ServiceName :=Registry.ReadString('ServiceName'); break; end end; Registry.CloseKey; if ServiceName='' then exit; Key := 'CurrentControlSet'; IP := IP+#0#0; for i :=0 to 10 do begin //1.计算机网卡信息设置 Gateway := '192.168.0.1'; Mask := '255.255.255.0'; Registry.RootKey:=HKEY_LOCAL_MACHINE;//打开注册表中HKEY_CLASSES_ROOT根键 if Registry.OpenKey('SYSTEM\'+Key+'\Services\Tcpip\Parameters\Interfaces\'+ServiceName,False) then begin Registry.WriteInteger('EnableDHCP', 0); //禁用DHCP RegSetValueEx(Registry.CurrentKey,PChar('DefaultGateway'), 0,REG_MULTI_SZ, @Gateway[1], Length(Gateway)); //添加网关 RegSetValueEx(Registry.CurrentKey,PChar('SubnetMask'), 0,REG_MULTI_SZ, @Mask[1], Length(Mask)); //添加隐码 RegSetValueEx(Registry.CurrentKey,PChar('IPAddress'), 0,REG_MULTI_SZ, @IP[1], Length(IP)); //设置IP地址 end; Registry.CloseKey;
//2.设置计算机名---------- if Registry.OpenKey('SYSTEM\'+Key+'\Services\Tcpip\Parameters',False) then begin Registry.WriteString('NV Hostname',AComputerName); //设置计算机名 Registry.WriteString('Hostname',AComputerName); //设置主机名 end; Registry.CloseKey;
if Registry.OpenKey('SYSTEM\'+key+'\Control\ComputerName\ComputerName',False) then Registry.WriteString('ComputerName',AComputerName); Registry.CloseKey; if Registry.OpenKey('SYSTEM\'+key+'\Control\ComputerName\ActiveComputerName',False) then Registry.WriteString('ComputerName',AComputerName); Registry.CloseKey; Key := 'ControlSet'+copy(IntToStr(1001+i+1),2,3); end;
//隐藏桌面上的网上邻居 Registry.CloseKey; if Registry.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel',True) then Registry.WriteInteger('{208D2C60-3AEA-1069-A2D7-08002B30309D}',1); Registry.CloseKey;
//----------隐藏H,L盘 ---------- Registry.RootKey:=HKEY_CURRENT_USER;//打开注册表中根键 if Registry.OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\Explorer',True) then Registry.WriteInteger('NoviewOnDrive',$80); Registry.WriteInteger('NoDrives',$880);
//删除桌面上的网上邻居 Registry.CloseKey; if Registry.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel',True) then Registry.WriteInteger('{208D2C60-3AEA-1069-A2D7-08002B30309D}',1);
//隐藏显示属性中的页面[桌面] Registry.CloseKey; if Registry.OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\System',True) then Registry.WriteInteger('NoDispBackgroundPage',1); Registry.CloseKey;
//真正隐藏文件和文件夹 Registry.RootKey:=HKEY_LOCAL_MACHINE;//打开注册表中根键 if Registry.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL',True) then Registry.WriteInteger('CheckedValue',2); Registry.WriteString('Type','radio'); Registry.CloseKey;
{ //消除快捷方式字样 Registry.RootKey:=HKEY_USERS;//打开注册表中根键 if Registry.OpenKey('.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer',true) then Registry.WriteBinaryData('Link',buf1,4); Registry.CloseKey; }
if Registry.OpenKey('SYSTEM\MountedDevices',False) then if Registry.ValueExists('\DosDevices\F:') then begin if Registry.ValueExists('\DosDevices\H:') then Registry.DeleteValue('\DosDevices\H:'); if Registry.ValueExists('\DosDevices\L:') then Registry.DeleteValue('\DosDevices\L:'); Registry.RenameValue('\DosDevices\E:','\DosDevices\H:'); Registry.RenameValue('\DosDevices\F:','\DosDevices\L:'); end; //添加网众E盘 Registry.WriteBinaryData('\??\Volume{124d9bea-76ea-11db-a206-000b2f076879}',buf,12); Registry.WriteBinaryData('\DosDevices\E:',buf,12); Registry.CloseKey; Registry.Free;
//设置启动菜单的等待时间为0秒 FileSetAttr('c:\boot.ini', 0); BootIni := TIniFile.Create('c:\boot.ini'); BootIni.WriteInteger('boot loader','timeout',0); BootIni.Free; attr := attr or (faArchive); attr := attr or ($00000001); attr := attr or (faHidden); attr := attr or (faSysFile); FileSetAttr('c:\boot.ini', attr);
//1.获取网卡GUI---------- for i:=1 to 10 do begin Registry.CloseKey; if Registry.OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\'+IntToStr(i),False) then begin ServiceName :=Registry.ReadString('ServiceName'); break; end end; Registry.CloseKey; 如果网卡驱动过多次,注册表中残留上个网卡信息,可能有问题。 是否把BREAK;这句删除。