システムの現在日付・時刻を取得 <TOP>
GetSystemTime システムの現在の日付と時刻を取得
日付・曜日・時刻(世界協定時刻)を取得します。
today$関数では曜日の取得はできない
参照
'================================================================ '= システムの現在日付・時刻を取得 '= (GetSystemTime.bas) '================================================================ #include "Windows.bi" Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type ' 現在の世界協定時刻の取得 Declare Sub Api_GetSystemTime Lib "Kernel32" Alias "GetSystemTime" (lpSystemTime As SYSTEMTIME) Var Shared Text(3) As Object Var Shared Button1 As Object For i = 0 To 3 Text(i).Attach GetDlgItem("Text" & Trim$(Str$(i + 1)))
Text(i).SetFontSize 14 Next i Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var st As SYSTEMTIME 'システムの現在の日付と時刻を取得 Api_GetSystemTime st 'システムの現在の日付と時刻を表示 Text(0).SetWindowText Str$(st.wYear) & "年" & Str$(st.wMonth) & "月" & Str$(st.wDay) & "日" & "(" & kMid$("日月火水木金土", st.wDayOfWeek + 1, 1) & ")" Text(1).SetWindowText Str$(st.wHour) & "時" & Str$(st.wMinute) & "分" & Str$(st.wSecond) & "秒" End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End