Fix safe work
This commit is contained in:
+15
-3
@@ -50,17 +50,29 @@ end;
|
||||
|
||||
procedure TFormHelper.SetWindowColorMode(IsDark: Boolean);
|
||||
begin
|
||||
SetWindowColorModeFor(handle, IsDark);
|
||||
try
|
||||
SetWindowColorModeFor(handle, IsDark);
|
||||
except
|
||||
//
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFormHelper.SetWindowColorModeAsSystem;
|
||||
begin
|
||||
SetWindowColorModeAsSystemFor(Handle);
|
||||
try
|
||||
SetWindowColorModeAsSystemFor(Handle);
|
||||
except
|
||||
//
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TFormHelper.SystemIsDarkMode: Boolean;
|
||||
begin
|
||||
Result := IsDarkMode;
|
||||
try
|
||||
Result := IsDarkMode;
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
{$ELSE}
|
||||
|
||||
+10
-6
@@ -123,13 +123,17 @@ var
|
||||
LRegistry: TRegistry;
|
||||
begin
|
||||
Result := False;
|
||||
LRegistry := TRegistry.Create;
|
||||
try
|
||||
LRegistry.RootKey := HKEY_CURRENT_USER;
|
||||
if LRegistry.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize') then
|
||||
Result := not LRegistry.ReadBool('AppsUseLightTheme');
|
||||
finally
|
||||
LRegistry.Free;
|
||||
LRegistry := TRegistry.Create;
|
||||
try
|
||||
LRegistry.RootKey := HKEY_CURRENT_USER;
|
||||
if LRegistry.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize') then
|
||||
Result := not LRegistry.ReadBool('AppsUseLightTheme');
|
||||
finally
|
||||
LRegistry.Free;
|
||||
end;
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user