Fix safe work

This commit is contained in:
alinvip22@gmail.com
2023-05-06 11:54:48 +05:00
parent 0c887a8980
commit 329ea5a41b
2 changed files with 25 additions and 9 deletions
+15 -3
View File
@@ -50,17 +50,29 @@ end;
procedure TFormHelper.SetWindowColorMode(IsDark: Boolean); procedure TFormHelper.SetWindowColorMode(IsDark: Boolean);
begin begin
SetWindowColorModeFor(handle, IsDark); try
SetWindowColorModeFor(handle, IsDark);
except
//
end;
end; end;
procedure TFormHelper.SetWindowColorModeAsSystem; procedure TFormHelper.SetWindowColorModeAsSystem;
begin begin
SetWindowColorModeAsSystemFor(Handle); try
SetWindowColorModeAsSystemFor(Handle);
except
//
end;
end; end;
class function TFormHelper.SystemIsDarkMode: Boolean; class function TFormHelper.SystemIsDarkMode: Boolean;
begin begin
Result := IsDarkMode; try
Result := IsDarkMode;
except
Result := False;
end;
end; end;
{$ELSE} {$ELSE}
+10 -6
View File
@@ -123,13 +123,17 @@ var
LRegistry: TRegistry; LRegistry: TRegistry;
begin begin
Result := False; Result := False;
LRegistry := TRegistry.Create;
try try
LRegistry.RootKey := HKEY_CURRENT_USER; LRegistry := TRegistry.Create;
if LRegistry.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize') then try
Result := not LRegistry.ReadBool('AppsUseLightTheme'); LRegistry.RootKey := HKEY_CURRENT_USER;
finally if LRegistry.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize') then
LRegistry.Free; Result := not LRegistry.ReadBool('AppsUseLightTheme');
finally
LRegistry.Free;
end;
except
Result := False;
end; end;
end; end;