1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| program *****************;
{$APPTYPE CONSOLE}
uses
Windows,
SysUtils,
Registry;
var
Registre : TRegistry;
F: TextFile;
I: Integer;
const
HKCU_Keys: array[0..5] of string = (
'Desktop', 'Favorites', 'Programs', 'Start Menu', 'Startup', 'Local AppData');
HKCU_Sets: array[0..5] of string = (
'desktop', 'favorites', 'startprg', 'startm', 'startup', 'dsculsad');
HKLM_Keys: array[0..4] of string = (
'Common Desktop', 'Common Favorites', 'Common Programs', 'Common Start Menu',
'Common Startup');
HKLM_Sets: array[0..4] of string = (
'audesktop', 'aufavorites', 'austartprg', 'austartm', 'austartup');
function ConvertirClef(const AValue: string): string;
begin
SetLength(result, Length(AValue));
CharToOEM(PChar(AValue), PChar(result));
result := AnsiLowercase(result);
end;
begin
ChDir(IncludeTrailingPathDelimiter(GetEnvironmentVariable('HOMEDRIVE')));
AssignFile(f, 'extract.bat');
Rewrite(F);
Writeln(F, 'echo off');
Writeln(F, '');
Registre := TRegistry.Create;
try
with registre do
begin
RootKey := HKEY_CURRENT_USER;
OpenKey('\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders',False);
for I := Low(HKCU_Keys) to High(HKCU_Keys) do
Writeln(F, 'Set ' + HKCU_Sets[i] + '=' + ConvertirClef(ReadString(HKCU_Keys[i]))) ;
CloseKey;
RootKey := HKEY_LOCAL_MACHINE;
OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders',False);
for I := Low(HKLM_Keys) to High(HKLM_Keys) do
Writeln(F, 'Set ' + HKLM_Sets[i] + '=' + ConvertirClef(ReadString(HKLM_Keys[i])));
CloseKey;
end;
finally
Registre.Free;
CloseFile(F);
end;
end. |
Partager