Delphi獲取Windows系統的當前時間,功能比較單一,除了獲取系統時間外,沒有其它功能。為了便於測試,這裡寫成了一個窗口程序,只需點擊按鈕即可一鍵獲取Windows時間,新手參考:
01
unit
Unit1;
02
interface
03
uses
04
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
05
Dialogs, StdCtrls;
06
type
07
TForm1 =
class
(TForm)
08
Label1: TLabel;
09
Button1: TButton;
10
procedure
Button1Click(Sender: TObject);
11
private
12
{ Private declarations }
13
public
14
{ Public declarations }
15
end
;
16
var
17
Form1: TForm1;
18
implementation
19
{$R *.dfm}
20
procedure
TForm1
.
Button1Click(Sender: TObject);
21
begin
22
Label1
.
Caption := FormatDateTime(
'hh:nn:ss'
,Now())
23
end
;
24
end
.
運行界面如圖: