Fix safe work
This commit is contained in:
+15
-3
@@ -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
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user