blob: ab4761aee60855b8107d6eac16addb288ceed478 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
{%mainunit fpg_utils.pas}
uses
Shellapi, Windows, fpg_constants, fpg_stringutils;
// GDI specific implementations of encoding functions
function fpgToOSEncoding(aString: TfpgString): string;
begin
Result := Utf8ToAnsi(aString);
end;
function fpgFromOSEncoding(aString: string): TfpgString;
begin
Result := AnsiToUtf8(aString);
end;
procedure fpgOpenURL(const aURL: TfpgString);
begin
try
{$IFNDEF wince}
ShellExecute(0, 'open', PChar(aURL), nil, nil, 1 {SW_SHOWNORMAL});
{$ENDIF}
except
// do nothing
end;
end;
function fpgFileSize(const AFilename: TfpgString): integer;
var
FindData: TWIN32FindDataW;
FindHandle: THandle;
Str: widestring;
begin
// Don't assign the widestring to TSearchRec.name because it is of type
// string, which will generate a conversion to the system encoding
Str := UTF8Decode(AFilename);
FindHandle:=Windows.FindFirstFileW(PWideChar(Str), FindData);
if FindHandle=Windows.Invalid_Handle_value then
begin
Result:=-1;
exit;
end;
Result := (int64(FindData.nFileSizeHigh) shl 32)+FindData.nFileSizeLow;
Windows.FindClose(FindHandle);
end;
|