FIX: Crash on startup under Windows (fixes #2033)

This commit is contained in:
Alexander Koblov 2024-12-29 13:53:35 +03:00
commit 87f8ba928f
3 changed files with 8 additions and 17 deletions

View file

@ -414,9 +414,6 @@ var
implementation
uses
{$IF DEFINED(MSWINDOWS)}
uMyWindows,
{$ENDIF}
uDebug, uFileSourceManager, uFileSourceListOperation, uLng;
{ TFileSource }
@ -803,7 +800,10 @@ end;
function TFileSource.IsSystemFile(aFile: TFile): Boolean;
begin
{$IF DEFINED(MSWINDOWS)}
Result := mbWinIsSystemFile(aFile);
if fpAttributes in aFile.SupportedProperties then
Result := TFileAttributesProperty(aFile.Properties[fpAttributes]).IsSysFile
else
Result := False;
{$ELSEIF DEFINED(DARWIN)}
if (Length(aFile.Name) > 1) and (aFile.Name[1] = '.') and (aFile.Name <> '..') then exit(true);
if aFile.Name='Icon'#$0D then exit(true);

View file

@ -364,7 +364,7 @@ uses
{$IFDEF MSWINDOWS}
, ActiveX, CommCtrl, ShellAPI, Windows, DCFileAttributes, uBitmap, uGdiPlus,
DCConvertEncoding, uShlObjAdditional, uShellFolder,
uShellFileSourceUtil, uMyWindows
uShellFileSourceUtil
{$ELSE}
, StrUtils, Types, DCBasicTypes
{$ENDIF}
@ -2068,6 +2068,7 @@ var
dwFileAttributes: DWORD;
uFlags: UINT;
const
FILE_ATTRIBUTE_ICON = FILE_ATTRIBUTE_READONLY or FILE_ATTRIBUTE_SYSTEM;
FILE_ATTRIBUTE_SHELL = FILE_ATTRIBUTE_DEVICE or FILE_ATTRIBUTE_VIRTUAL;
{$ENDIF}
begin
@ -2128,7 +2129,7 @@ begin
if (IconsMode = sim_standart) or
// Directory has special icon only if it has "read only" or "system" attributes
// and contains desktop.ini file
(not (DirectAccess and (mbWinIsSystemFile(aFile) or FileIsReadOnly(Attributes)) and mbFileExists(FullPath + '\desktop.ini'))) or
(not (DirectAccess and ((Attributes and FILE_ATTRIBUTE_ICON) <> 0) and mbFileExists(FullPath + '\desktop.ini'))) or
(ScreenInfo.ColorDepth < 16) then
{$ELSEIF DEFINED(UNIX) AND NOT (DEFINED(DARWIN) OR DEFINED(HAIKU))}
if (IconsMode = sim_all_and_exe) and (DirectAccess) then

View file

@ -26,8 +26,7 @@ unit uMyWindows;
interface
uses
Graphics, Classes, SysUtils, JwaWinType, JwaWinBase, JwaNative, Windows,
uFile, uFileProperty;
Graphics, Classes, SysUtils, JwaWinType, JwaWinBase, JwaNative, Windows;
const
// STORAGE_BUS_TYPE
@ -112,7 +111,6 @@ function mbWinNetErrorMessage(dwError: DWORD): String;
{en
Retrieves the current status of the specified service
}
function mbWinIsSystemFile(const aFile: TFile): Boolean;
function GetServiceStatus(const AName: String): DWORD;
{en
The QueryDirectoryFile routine returns various kinds of information
@ -732,14 +730,6 @@ begin
if (Length(Result) = 0) then Result:= Format(SUnknownErrorCode, [dwError]);
end;
function mbWinIsSystemFile(const aFile: TFile): Boolean;
begin
if fpAttributes in aFile.SupportedProperties then
Result := TFileAttributesProperty(aFile.Properties[fpAttributes]).IsSysFile
else
Result := False;
end;
function GetServiceStatus(const AName: String): DWORD;
var
hSCManager, hService: SC_HANDLE;