diff options
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r-- | Game/Code/Classes/UPlatformWindows.pas | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/Game/Code/Classes/UPlatformWindows.pas b/Game/Code/Classes/UPlatformWindows.pas index afdcebcf..93e72e7a 100644 --- a/Game/Code/Classes/UPlatformWindows.pas +++ b/Game/Code/Classes/UPlatformWindows.pas @@ -11,7 +11,7 @@ interface uses Classes, UPlatform;
type
-
+
TPlatformWindows = class(TPlatform)
public
Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; override;
@@ -23,7 +23,7 @@ implementation uses SysUtils, Windows;
type
-
+
TSearchRecW = record
Time: Integer;
Size: Integer;
@@ -45,7 +45,11 @@ const faSpecial = faHidden or faSysFile or faVolumeID or faDirectory;
begin
F.ExcludeAttr := not Attr and faSpecial;
+{$IFDEF Delphi}
F.FindHandle := FindFirstFileW(PWideChar(Path), F.FindData);
+{$ELSE}
+ F.FindHandle := FindFirstFileW(PWideChar(Path), @F.FindData);
+{$ENDIF}
if F.FindHandle <> INVALID_HANDLE_VALUE then
begin
Result := FindMatchingFileW(F);
@@ -56,7 +60,11 @@ end; function FindNextW(var F: TSearchRecW): Integer;
begin
+{$IFDEF Delphi}
if FindNextFileW(F.FindHandle, F.FindData) then
+{$ELSE}
+ if FindNextFileW(F.FindHandle, @F.FindData) then
+{$ENDIF}
Result := FindMatchingFileW(F)
else
Result := GetLastError;
@@ -78,7 +86,11 @@ begin with F do
begin
while FindData.dwFileAttributes and ExcludeAttr <> 0 do
+{$IFDEF Delphi}
if not FindNextFileW(FindHandle, FindData) then
+{$ELSE}
+ if not FindNextFileW(FindHandle, @FindData) then
+{$ENDIF}
begin
Result := GetLastError;
Exit;
@@ -101,31 +113,31 @@ begin end;
//------------------------------
-//Start more than One Time Prevention -//------------------------------ +//Start more than One Time Prevention
+//------------------------------
function TPlatformWindows.TerminateIfAlreadyRunning(var WndTitle : String) : Boolean;
var
hWnd: THandle;
- I: Integer; + I: Integer;
begin
Result := false;
hWnd:= FindWindow(nil, PChar(WndTitle));
- //Programm already started - if (hWnd <> 0) then - begin - I := Messagebox(0, PChar('Another Instance of Ultrastar is already running. Continue ?'), PChar(WndTitle), MB_ICONWARNING or MB_YESNO); - if (I = IDYes) then - begin - I := 1; - repeat - Inc(I); - hWnd := FindWindow(nil, PChar(WndTitle + ' Instance ' + InttoStr(I))); - until (hWnd = 0); - WndTitle := WndTitle + ' Instance ' + InttoStr(I); - end - else - Result := true; - end; + //Programm already started
+ if (hWnd <> 0) then
+ begin
+ I := Messagebox(0, PChar('Another Instance of Ultrastar is already running. Continue ?'), PChar(WndTitle), MB_ICONWARNING or MB_YESNO);
+ if (I = IDYes) then
+ begin
+ I := 1;
+ repeat
+ Inc(I);
+ hWnd := FindWindow(nil, PChar(WndTitle + ' Instance ' + InttoStr(I)));
+ until (hWnd = 0);
+ WndTitle := WndTitle + ' Instance ' + InttoStr(I);
+ end
+ else
+ Result := true;
+ end;
end;
Function TPlatformWindows.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray;
|