2012-01-12 258 views
1

请让我知道如何获得Inno Setup中当前的Unix时间戳?如何在Inno Setup中获取当前的Unix时间戳?

+0

对不起,不是编程问题,请尝试http://superuser.com/或http://serverfault.com/。 (我没有downvote你的问题)。祝你好运。 – shellter 2012-01-12 14:16:28

+0

@Shelter - 是的,InnoSetup内置了Pascal脚本,这是您获得单位时间戳的唯一方法。 – 2012-01-12 15:59:05

回答

2

最简单的方法是使用time()函数从C运行时库,它具有以下返回值:

返回自午夜秒流逝的时间,1970年1月1日或 -1在出现错误的情况下。

这正是unix timestamp所在。

现在将这个函数导入Inno Setup脚本是一件简单的事情。由于脚本环境不知道指针参数(幸运的是不需要指向一个有效的缓冲,查看链接文档)是作为整数和你必须传递一个0吧:

function Time(ATimerPtr: integer): integer; external '[email protected] cdecl'; 

function InitializeSetup(): Boolean; 
begin 
    MsgBox(Format('unix timestamp: %d', [Time(0)]), mbInformation, MB_OK); 
end; 
+0

_time32可从Vista获得,如果您想要支持WinXP,请使用[email protected] – ariwez 2013-10-11 11:34:24