Hier mal der aktualisierte und korrigierte Source Code:
Delphi-Quellcode:
procedure TForm1.Button30Click(Sender: TObject);
var
regKey : TRegistry;
begin
//Create Object
regKey := TRegistry.Create(KEY_READ AND KEY_WOW64_64KEY);
Try
//Set Root Key
regKey.RootKey := HKEY_LOCAL_MACHINE;
//Open Registry Key
If Not(regKey.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate')) Then
Begin
MessageDlg('Could not open Registry Key!', mtError, [mbOK], 0);
End Else
Begin
//Read Registry Key
ShowMessage(regKey.ReadString('AUState'));
End;
//Close Registry Key
regKey.CloseKey();
Finally
regKey.Free;
End;
end;