Platform Specific Code in Delphi

{IFDEF Platform(iOS)}

{ENDif}

Advertisements

Get ShellExecute Error in Delphi

ExecuteResult:=ShellExecute(Handle, 'open', PChar(filename), nil, nil, SW_HIDE);

case ExecuteResult of
 0 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': The operating system is out of memory or resources.');
 2 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': The specified file was not found.');
 3 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': The specified path was not found.');
 5 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Windows 95 only: The operating system denied access to the specified file.');
 8 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Windows 95 only: There was not enough memory to complete the operation.');
 10 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Wrong Windows version.');
 11 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).');
 12 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Application was designed for a different operating system.');
 13 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Application was designed for MS-DOS 4.0.');
 15 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Attempt to load a real-mode program.');
 16 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Attempt to load a second instance of an application with non-readonly data segments.');
 19 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Attempt to load a compressed application file.');
 20 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Dynamic-link library (DLL) file failure.');
 26 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': A sharing violation occurred.');
 27 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': The filename association is incomplete or invalid.');
 28 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': The DDE transaction could not be completed because the request timed out.');
 29 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': The DDE transaction failed.');
 30 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': The DDE transaction could not be completed because other DDE transactions were being processed.');
 31 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': There is no application associated with the given filename extension.');
 32 : ShowMessage('Error ' + IntToStr(ExecuteResult) + ': Windows 95 only: The specified dynamic-link library was not found.');
 end;

Inno Setup Languages

Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.islu"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "greek"; MessagesFile: "compiler:Languages\Greek.isl"
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
Name: "nepali"; MessagesFile: "compiler:Languages\Nepali.islu"
Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.isl"
Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"

Get Windows Language in English

function GetLocaleInformation(Flag: Integer): string;
var
 pcLCA: array [0..20] of Char;
begin
 if GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, Flag, pcLCA, 19) <= 0 then
 pcLCA[0] := #0;
 Result := pcLCA;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
 ShowMessage(GetLocaleInformation(LOCALE_SENGLANGUAGE));
end;

Result are like:

French

German

Japanese

kSign and Inno Setup Configuration

In Inno Setup:

Tools->Configure Sign Tools…

Add New:

Name: mysigntool

Value: “C:\Program Files (x86)\kSign\signtool.exe” sign /f “C:\Program Files (x86)\kSign\MyCertificate.pfx” /t http://timestamp.verisign.com/scripts/timstamp.dll $f

OR

Value: “C:\Program Files (x86)\kSign\signtool.exe” sign /f “C:\Program Files (x86)\kSign\MyCertificate.pfx” /p MYPASSWORD /t http://timestamp.verisign.com/scripts/timstamp.dll $f

[Setup]
SignTool=mysigntool

TPath.DirectorySeparatorChar

(Delphi uses System.IOUtils)

Different versions of Windows seem to behave differently (e.g. \ and / both work on the English versions)

¥ : Japanese version

₩ : Korean version

While the ₩ and ¥ characters are shown as directory separator symbols in the respective Korean and Japanese windows versions, they are only how those versions of Windows represent the same Unicode code point U+005c as a glyph. The underlying code point for backslash is still the same across English Windows and the Japanese and Korean windows versions.

Also, I don’t know of any Windows API function that gets you the system’s path separator, but you can rely on it being \ in all circumstances.

Note File I/O functions in the Windows API convert “/” to “\” as part of converting the name to an NT-style name, except when using the “\?\” prefix as detailed in the following sections.