Search code examples
delphiexcellocaleinno-setuppascal

Inno Setup: Specify Date in local format


My application uses Inno Setup to create some registry settings which are later read by an Excel addin. One of these settings is a date.

What I am looking for is a function (in Inno-Setup-friendly Pascal) that takes a date (formatted as a string) and outputs it using the local system date format on whatever computer it runs on. Something like

function GetLocalVersionOfShortDate(dateString : String): String;
begin
 // take dateString and convert/display it as local date
end;

The output should be in short date format with the local date separator.

For example, I would pass "January 20, 1980" to this function and it would return "01/20/1980" (in America) and "20/01/1980" (in France).

Any thoughts on how to do that? I feel like it's something simple but I'm not familiar enough with Pascal to write the code myself.

Thank you!


Solution

  • There might be a way of doing this by calling into Windows libraries.

    Check the section in the INNO help file called "Pascal Scripting: Using DLLs".

    http://www.jrsoftware.org/ishelp/

    ALTERNATIVE 1

    You could do this by running an executable from either the Run section or via a function using the Exec method. If you are just writing registry settings then this should suffice. Then after the executable has run you could remove it by defining your own ssPostInstall method.