날짜/시간형식 변경 및 강제 시간세팅
procedure TForm1.Button1Click(Sender: TObject);
var
lngLocale, UserLocale, Locate: Cardinal;
s_time : TSystemTime;
sysTime : String;
iDay, iHour : Integer;
begin
lngLocale := GetSystemDefaultLCID;
UserLocale := GetUserDefaultLCID;
Locate := LOCALE_ITIMEMARKPOSN;
If SetLocaleInfo(lngLocale, LOCALE_SSHORTDATE, 'yyyy-MM-dd') Then
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)
Else
ShowMessage('날짜형식 변경실패');
If SetLocaleInfo(UserLocale, LOCALE_STIMEFORMAT, 'tt h:mm:ss') Then
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)
Else
ShowMessage('시간형식 변경실패');
// SELECT TO_CHAR(SYSDATE ,'YYYY-MM-DD HH24:MI:SS') SYSTIME FROM DUAL
sysTime := '2014-02-03 04:40:57';
s_time.wYear := StrToInt(Copy(sysTime, 1, 4));
s_time.wMonth := StrToInt(Copy(sysTime, 6, 2));
iHour := StrToInt(Copy(sysTime, 12, 2));
If iHour <= 8 Then // iHour = 0 -> 14시, 23 -> 08시, 24 -> 09시
Begin
Inc(iHour, 24);
iDay := 1;
End
Else
iDay := 0;
s_time.wDay := StrToInt(Copy(sysTime, 9, 2)) - iDay;
s_time.wHour := iHour - 9;
s_time.wMinute := StrToInt(Copy(sysTime, 15, 2));
s_time.wSecond := StrToInt(Copy(sysTime, 18, 2));
SetSystemTime(s_time);
end;
'Delphi' 카테고리의 다른 글
델파이 API (0) | 2014.02.13 |
---|---|
Q&A 정리 (0) | 2014.02.13 |
Tip 정리 (0) | 2014.02.13 |
올림 / 내림(버림) (0) | 2011.08.03 |
델파이의 소숫점 반올림 방식 (2) | 2011.08.03 |