I am trying to get the Value of an entry in the Registry in Delphi.
typing in reg query HKLM\SOFTWARE\Microsoft\Cryptography /v MachineGuid
in the command line (regardless of running it as admin or not) works and outputs me the value I am looking for.
I would like Delphi to lookup that value too, but I can't get it to work.
I tried GetDosOutput (like this one) and I tried the Component DOSCommand (this one).
GetDosOutput and the Component DOSCommand are working very well or running other stuff (for example systeminfo
or getmac
or ipconfig
or even running some batch files)
but while trying the command reg query HKLM\SOFTWARE\Microsoft\Cryptography /v MachineGuid
using one of those methods to output the cmd content I get something like this: ERROR: The specified registry key or value was not found.
What works so far is this one: reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v MyApplication /f
and this one: REG ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /f /v BackgroundVideoUploader /t REG_SZ /d C:\temp\BackgroundVideoUploader.exe
I assume that I am not allowed to lookup HKLM but HKCU works. But even running my Delphi App as Administrator won't enable me to prform this command getting the desired output.
Even the TRegistry Component didnt output anything (empty string):
procedure TForm1.Button2Click(Sender: TObject);
var
Registry: TRegistry;
begin
Registry := TRegistry.Create(KEY_READ);
try
Registry.RootKey := HKEY_LOCAL_MACHINE;
Registry.OpenKey('SOFTWARE\Microsoft\Cryptography', False);
showmessage(Registry.ReadString('MachineGuid'));
finally
Registry.Free;
end;
end;
Can someone tell me why its not working and how I can get it running?