Difference of time |
尚未結案
|
chgtauhan
一般會員 發表:10 回覆:21 積分:6 註冊:2005-07-23 發送簡訊給我 |
Can i now how to calculate the difference of time.Here is the code i write: TTime d;
d=Time();
//do.....
Label1->Caption=Time()-d; The difference of time is calculated if your computer time system is set to 24 hours system. If your computer time system is set to 12 hours sistem, something weird is shown, example 12:00:01 am.
How to overcome this problem?
And then can i know how to calculate the difference of time until mili seconds....
Please.......
|
justdo
高階會員 發表:2 回覆:359 積分:222 註冊:2004-08-17 發送簡訊給我 |
|
andychang1690
資深會員 發表:20 回覆:694 積分:442 註冊:2003-03-14 發送簡訊給我 |
chgtauhan:方法有一些 一、你可以統一電腦時間格式 AnsiString sgs; sgs.SetLength(12); // 得到目前系統時間格式 GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_STIMEFORMAT ,sgs.c_str(),12); if (sgs.Trim() != "HH:mm:ss") { AnsiString str; str = "HH:mm:ss"; // HH:24小時制 hh:12小時制 if (SetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_STIMEFORMAT, str.c_str())) ShowMessage("更改時間格式成功"); } 二、使用DecodeTime,EncodeTime做運算 Word Hour,Min,Sec,mSec; TTime d; d=Time(); DecodeTime(d,Hour,Min,Sec,mSec); d =EncodeTime((Word)Hour, (Word)Min, (Word)Sec, (Word)mSec); 三、直接如你一般直接運算!(只要時間格式如一般統一) 請參考!Andy Chang
------
Andy Chang |
chgtauhan
一般會員 發表:10 回覆:21 積分:6 註冊:2005-07-23 發送簡訊給我 |
|
andychang1690
資深會員 發表:20 回覆:694 積分:442 註冊:2003-03-14 發送簡訊給我 |
chgtauhan:因為使用了windows API函數 int GetLocaleInfo( LCID Locale, // locale identifier LCTYPE LCType, // type of information LPTSTR lpLCData, // address of buffer for information int cchData // size of buffer ); 而最長的時間格式為:tt hh:mm:ss(11位數) 所以我習慣設為12,你可以試試 AnsiString sgs; sgs.SetLength(12); // 得到目前系統時間格式 GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_STIMEFORMAT ,sgs.c_str(),12); Edit1->Text=sgs; 將12改為6出現HH:mm: 將12改為7出現HH:mm:s 8以上為HH:mm:ss 請參考!Andy Chang
------
Andy Chang |
chgtauhan
一般會員 發表:10 回覆:21 積分:6 註冊:2005-07-23 發送簡訊給我 |
|
chgtauhan
一般會員 發表:10 回覆:21 積分:6 註冊:2005-07-23 發送簡訊給我 |
here is the code:
AnsiString sgs; sgs.SetLength(12); // 得到目前系統時間格式 GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_STIMEFORMAT ,sgs.c_str(),12); if (sgs.Trim() != "HH:mm:ss") { AnsiString str; str = "HH:mm:ss"; // HH:24小時制 hh:12小時制 if (SetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_STIMEFORMAT, str.c_str())) ShowMessage("更改時間格式成功"); }after i apply the code above, it only change the format but it doesn't apply to the cpu. how to apply to the cpu? |
andychang1690
資深會員 發表:20 回覆:694 積分:442 註冊:2003-03-14 發送簡訊給我 |
引言: here is the code:AnsiString sgs; sgs.SetLength(12); // 得到目前系統時間格式 GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_STIMEFORMAT ,sgs.c_str(),12); if (sgs.Trim() != "HH:mm:ss") { AnsiString str; str = "HH:mm:ss"; // HH:24小時制 hh:12小時制 if (SetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_STIMEFORMAT, str.c_str())) ShowMessage("更改時間格式成功"); }after i apply the code above, it only change the format but it doesn't apply to the cpu. how to apply to the cpu? chgtauhan:這可難倒我了,我確定我的程式可以更改Windows系統上 的日期及時間設置,但CPU............?!Andy Chang
------
Andy Chang |
chgtauhan
一般會員 發表:10 回覆:21 積分:6 註冊:2005-07-23 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |