Hi!
I've coded under Windows XP the following program which should show the ProcessorNameString from the key HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/0 by using the command "showmessage":
unit unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons, Registry;
type
TForm1 = class(TForm)
Button1: TBUTTON;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
reg: TRegistry;
result: string;
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
result:= '0';
reg:=TRegistry.Create;
try
reg.RootKey := HKEY_LOCAL_MACHINE;
if reg.OpenKey('Hardware\Description\System\CentralProcessor\0\', false) then
begin
result:=reg.ReadString('ProcessorNameString');
end;
finally
reg.free;
end;
showmessage(result);
end;
initialization
{$I unit1.lrs}
end.
I don't know what I'm doing wrong, because it's working with Delphi without any problem. When I'm running it with Lazarus, I get '0' on the screen and with a more simple made code I got the message "EREGISTRYEXCEPTION: Invalid
Registry Data Type". TRegistry seems not really to be good included into the compiler because I also can't use "key_read" only for example!?
Please help me guys! Thank you very much!
Greetings,
Armin