Skip to content

Commit

Permalink
Avoid registry exception on not found values
Browse files Browse the repository at this point in the history
  • Loading branch information
vhanla committed Jun 27, 2019
1 parent 062e18d commit 8d0e38c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion WinXCorners.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<FrameworkType>VCL</FrameworkType>
<MainSource>WinXCorners.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Config Condition="'$(Config)'==''">Release</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Application</AppType>
Expand Down
Binary file modified WinXCorners.res
Binary file not shown.
29 changes: 17 additions & 12 deletions functions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ function isWindows10:boolean;
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows NT\CurrentVersion') then
begin
if (Reg.ReadString('CurrentVersion') = '6.3')
and (StrToInt (Reg.ReadString('CurrentBuildNumber')) >= 10240) then
Result := True;
if Reg.ValueExists('CurrentVersion') then
if (Reg.ReadString('CurrentVersion') = '6.3')
and (StrToInt (Reg.ReadString('CurrentBuildNumber')) >= 10240) then
Result := True;
end;
finally
Reg.Free;
Expand All @@ -210,9 +211,10 @@ function isAcrylicSupported:boolean;
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows NT\CurrentVersion') then
begin
if (Reg.ReadString('CurrentVersion') = '6.3')
and (StrToInt(Reg.ReadString('CurrentBuildNumber')) >= 17134) then
Result := True;
if Reg.ValueExists('CurrentVersion') then
if (Reg.ReadString('CurrentVersion') = '6.3')
and (StrToInt(Reg.ReadString('CurrentBuildNumber')) >= 17134) then
Result := True;
end;
finally
Reg.Free;
Expand All @@ -231,8 +233,9 @@ function SystemUsesLightTheme:boolean;
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKeyReadOnly('Software\Microsoft\Windows\CurrentVersion\Themes\Personalize') then
begin
if (Reg.ReadInteger('SystemUsesLightTheme') = 1) then
Result := True;
if Reg.ValueExists('SystemUsesLightTheme') then
if (Reg.ReadInteger('SystemUsesLightTheme') = 1) then
Result := True;
end;
finally
Reg.Free;
Expand Down Expand Up @@ -304,8 +307,9 @@ function TaskbarTranslucent: Boolean;
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize');
try
if reg.ReadInteger('EnableTransparency') = 1 then
Result := True;
if reg.ValueExists('EnableTransparency') then
if reg.ReadInteger('EnableTransparency') = 1 then
Result := True;
except
Result := False;
end;
Expand All @@ -326,8 +330,9 @@ function TaskbarAccented:Boolean;
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize');
try
if reg.ReadInteger('ColorPrevalence') = 1 then
Result := True;
if reg.ValueExists('ColorPrevalence') then
if reg.ReadInteger('ColorPrevalence') = 1 then
Result := True;
except
Result := False;
end;
Expand Down

0 comments on commit 8d0e38c

Please sign in to comment.