Opis węzła rejestru w Win64
Mam jeden projekt Delphi XE2, aby utworzyć jakiś węzeł i podwęzły w rejestrze systemu Windows, jak opisano poniżej:
Zdefiniowałem następujące kody:
function GetWinDir: string;
var
WindowsDirectory: array[0..MAX_PATH] of Char;
begin
GetWindowsDirectory(WindowsDirectory, MAX_PATH - 1);
SetLength(Result, StrLen(WindowsDirectory));
Result := IncludeTrailingPathDelimiter(WindowsDirectory);
end;
function GetSysDir: string;
var
SystemDirectory: array[0..MAX_PATH] of Char;
begin
GetSystemDirectory(SystemDirectory, MAX_PATH - 1);
SetLength(Result, StrLen(SystemDirectory));
Result := IncludeTrailingPathDelimiter(SystemDirectory);
end;
function GetSysNativeDir: string;
var
WindowsDirectory: array[0..MAX_PATH] of Char;
begin
GetWindowsDirectory(WindowsDirectory, MAX_PATH - 1);
SetLength(Result, StrLen(WindowsDirectory));
Result := IncludeTrailingPathDelimiter(WindowsDirectory) + 'Sysnative\';
end;
procedure TMainForm.BitBtn01Click(Sender: TObject);
var
RegistryEntry : TRegistry;
RegistryEntryValue : string;
begin
RegistryEntry := TRegistry.Create(KEY_READ or KEY_WOW64_64KEY);
RegistryEntry.RootKey := HKEY_CLASSES_ROOT;
if (not RegistryEntry.KeyExists('CLSID\{BE800AEB-A440-4B63-94CD-AA6B43647DF9}\')) then
begin
RegistryEntry.Access:= KEY_WRITE or KEY_WOW64_64KEY;
if RegistryEntry.OpenKey('CLSID\{00000000-0000-0000-0000-000000000001}\',true) then
begin
Memo01.Font.Color := 3992580;
Memo01.Lines.Add('Windows Registry Entry Has Been Found In Your System');
RegistryEntry.WriteString('', 'Delphi Application Wizard');
RegistryEntry.OpenKey('Subnode 01\',true);
RegistryEntry.WriteExpandString('', '%SystemRoot%\System32\Application Wizard 01.dll');
RegistryEntry.WriteString('Subnode String 01', '00001');
RegistryEntry.CloseKey();
RegistryEntry.OpenKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 02\',true);
RegistryEntry.WriteExpandString('', '%SystemRoot%\System32\Application Wizard 02.dll');
RegistryEntry.WriteString('Subnode String 02', '00002');
RegistryEntry.CloseKey();
RegistryEntry.OpenKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 03\',true);
RegistryEntry.WriteExpandString('', '%SystemRoot%\System32\Application Wizard 03.dll');
RegistryEntry.WriteString('Subnode String 03', '00003');
RegistryEntry.CloseKey();
RegistryEntry.OpenKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 04\',true);
RegistryEntry.WriteExpandString('', '%SystemRoot%\System32\Application Wizard 04.dll');
RegistryEntry.WriteString('Subnode String 04', '00004');
RegistryEntry.CloseKey();
RegistryEntry.OpenKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 05\',true);
RegistryEntry.WriteExpandString('', '%SystemRoot%\System32\Application Wizard 05.dll');
RegistryEntry.WriteString('Subnode String 05', '00005');
Memo01.Font.Color := 3992580;
Memo01.Lines.Add('Windows Registry Entry Has Been Created Successfully')
end
else if RegistryEntry.OpenKey('CLSID\{00000000-0000-0000-0000-000000000001}\',false) then
begin
Memo01.Font.Color := 7864575;
Memo01.Lines.Add('Windows Registry Entry Has Not Been Created Successfully')
end
end
else
begin
if (RegistryEntry.KeyExists('CLSID\{00000000-0000-0000-0000-000000000001}\')) then
begin
Memo01.Font.Color := 7864575;
Memo01.Lines.Add('Windows Registry Entry Has Been Found In Your System')
end;
end;
RegistryEntry.CloseKey();
RegistryEntry.Free;
end;
..
..
..
..
..
procedure TMainForm.BitBtn02Click(Sender: TObject);
var
RegistryEntry : TRegistry;
begin
RegistryEntry := TRegistry.Create(KEY_READ or KEY_WOW64_64KEY);
RegistryEntry.RootKey := HKEY_CLASSES_ROOT;
if (RegistryEntry.KeyExists('CLSID\{00000000-0000-0000-0000-000000000001}\')) then
begin
Memo01.Font.Color := 3992580;
Memo01.Lines.Add('Windows Registry Entry Has Been Found In Your System');
RegistryEntry.Access:= KEY_WRITE or KEY_WOW64_64KEY;
RegistryEntry.DeleteKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 01\');
RegistryEntry.DeleteKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 02\');
RegistryEntry.DeleteKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 03\');
RegistryEntry.DeleteKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 04\');
RegistryEntry.DeleteKey('CLSID\{00000000-0000-0000-0000-000000000001}\Subnode 05\');
RegistryEntry.DeleteKey('CLSID\{00000000-0000-0000-0000-000000000001}\');
RegistryEntry.CloseKey();
RegistryEntry.Free;
Memo01.Font.Color := 16756480;
Memo01.Lines.Add('Windows Registry Entry Has Been Deleted Successfully');
end
else
begin
Memo01.Font.Color := 7864575;
Memo01.Lines.Add('Windows Registry Entry Has Not Been Found In Your System');
end;
end;
Moje pytanie brzmi:
Chociaż próbuję napisać domyślny ciąg dla każdego podwęzła jako%SystemRoot%\System32\Application Wizard 01.dll
jeszcze%SystemRoot%\SysWow64\Application Wizard 01.dll
jest napisane. Jak tego uniknąć?
Po napisaniu jakiegoś ciągu w podwęzle 01, kiedy próbuję napisać jakiś ciąg w podwęzle 02 itd., Czy za każdym razem muszę zadzwonićCloseKey();
iOpenKey
Węzeł główny lub nie, jak to zrobiłem w moich kodach. Czy jest jakieś inne rozwiązanie?
Jeśli chcę usunąć główny węzeł za pomocą niektórych kodów, muszę usunąć pierwszy podwęzeł 05, a następnie podwęzeł 04 ... i tak dalej. Dopiero po usunięciu wszystkich podwęzłów będę mógł usunąć główny węzeł. Jeśli jakieś podwęzły zawierają inne podwęzły, sprawdzę te rzeczy. Czy istnieje rozwiązanie, które zamiast usuwać te podwęzły, bezpośrednio usunie węzeł główny?