Windows 獲取檔案操作時間的方法

2021-07-08 19:38:42 字數 1068 閱讀 6511

一、獲取檔案的修改時間

/*

typedef struct _win32_find_dataa win32_find_dataa, *pwin32_find_dataa, *lpwin32_find_dataa;

*/``

舉例:#include////標頭檔案include

int main(int argc,char *argv)

2: 得到系統時間日期(使用getlocaltime)  

systemtime st;   

cstring strdate,strtime;   

getlocaltime(&st);   

strdate.format("%4d-%2d-%2d",st.wyear,st.wmonth,st.wday);   

strtime.format("%2d:%2d:%2d",st.whour,st.wminute,st.wsecond);

3.使用gettickcount//獲取程式執行時間  

long t1=gettickcount();//程式段開始前取得系統執行時間(ms)   

sleep(500); long t2=gettickcount();//程式段結束後取得系統執行時間(ms)   

str.format("time:%dms",t2-t1);//前後之差即 程式執行時間   

afxmessagebox(str);//獲取系統執行時間   

long t=gettickcount();   

cstring str,str1;   

str1.format("系統已執行 %d時",t/3600000);   

str=str1; t%=3600000;   

str1.format("%d分",t/60000);   

str+=str1; t%=60000;   

str1.format("%d秒",t/1000);   

str+=str1; afxmessagebox(str);

在windows上獲取檔案建立時間

目前在windows上測試成功,linux上可能是由問題的,在網上找了些資料,結合自己除錯結果,最終如下 遞迴獲取檔案 listfilelist new treelist public listfiles file file else return filelist 匯入測試環境 test publ...

獲取windows系統時間

獲取系統時間,這個方法比較簡單 sytimeemtime time getlocaltime time 獲得當前本地時間 getsytimeemtime time 這乙個是獲得格林威治時間,一般不用 sytimeemtime結構說明 typedef struct systemtime systemt...

windows獲取時間方法

方法一 用c語言庫函式中的time函式 ctime函式和ctime s 函式,精確到秒 time函式 標頭檔案 time.h 功能 獲取當前的系統時間,返回乙個time t型別 即乙個大整數 用法 time t time time t timer ctime函式 標頭檔案 time.h 功能 cti...