我有一个 Delphi XE2 项目来检查注册表项 MyCompanyName\1中的一个十六进制值。如果十六进制值是13,那么会有一些消息,否则会有一些其他消息。
所以我定义了以下代码:
procedure TMainForm.BitBtn01Click(Sender: TObject);
var
RegistryEntry : TRegistry;
begin
RegistryEntry := TRegistry.Create(KEY_READ or KEY_WOW64_64KEY);
RegistryEntry.RootKey := HKEY_LOCAL_MACHINE;
if (RegistryEntry.KeyExists('SOFTWARE\MyCompanyName\1\')) then
begin
if (RegistryEntry.OpenKey('SOFTWARE\MyCompanyName\1\',true)) then
begin
if (RegistryEntry.ReadString('SettingValue') = '0x00000013') then
begin
Memo01.Lines.Add('SettingHexadeciamlValue exist properly')
end
else
begin
Memo01.Lines.Add('SettingHexadeciamlValue does not exist properly')
end;
end
else
begin
if (RegistryEntry.OpenKey('SOFTWARE\MyCompanyName\1\',false)) then
begin
Memo01.Lines.Add('Unable to read RegistryKey ''MyCompanyName''Exiting.......')
end;
end;
end
else
begin
Memo01.Lines.Add('RegistryKey ''MyCompanyName'' does not exist')
end;
end;
编译后,当我运行应用程序AsAdministrator时,我收到错误提示Invalid data type for 'SettingValue'。