WindowsAPI獲取時間資訊

2021-06-11 07:38:52 字數 987 閱讀 3764

時間資訊

1.設定獲取系統時間

(1)關鍵api和資料結構

systemtime資料結構:

typedef

struct

_systemtime  systemtime, *psystemtime, *lpsystemtime;

api:

void

winapi

getlocaltime(

lpsystemtime

lpsystemtime

void

winapi

getsystemtime(

lpsystemtime

lpsystemtime

bool

winapi

setlocaltime(

const

systemtime *lpsystemtime

2.獲取開機至現在持續的時間

(1)關鍵api

dword

winapi

gettickcount(

void

返回ms數

3.檔案時間與系統時間的轉換

(1)關鍵api

和資料結構

typedef

struct

_filetime  filetime, *pfiletime, *lpfiletime;

轉換api:

bool

winapi

systemtimetofiletime(

const

systemtime *lpsystemtime,

lpfiletime

lpfiletime

bool

winapi

filetimetosystemtime(

const

filetime *lpfiletime,

lpsystemtime

lpsystemtime

Windows API 獲取系統路徑

但是這樣每次開發效率就比較低,所以還是整理下吧,加深下印象,至少後面可以在自己部落格裡就能輕鬆的找到了吧。直接上 吧。include stdafx.h include include include include define make pair id std pair id,t id void ...

Windows API獲取螢幕真實大小

在petzold的書中寫用getdevicecaps hdc,logpixelsx 得到螢幕dpi dot per inch 計算真實大小,但我實際操作了發現不對。在windows系統中,我得到logpixelsx為96,無論解析度怎麼調整都是96,也許是出於對文字顯示的考慮。我發現使用getdev...

微信小程式獲取當前時間戳 獲取當前時間 時間戳加減

獲取當前時間戳 var timestamp date.parse new date timestamp timestamp 1000 console.log 當前時間戳為 timestamp 獲取當前時間 var n timestamp 1000 var date new date n 年 var ...