Lm th? no ? chuy?n ?i m?t time_t UNIX ? m?t Win32 FILETIME ho?c SYSTEMTIME

D?ch tiu ? D?ch tiu ?
ID c?a bi: 167296 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

TM T?T

D?i n?n t?ng UNIX, t?p l?n ?c duy tr? ? d?ng ANSI C runtime s? h?c ki?u ?t tn l 'time_t', ?i di?n cho giy k? t? n?a m 1 thng 1 nm 1970 UTC (gi? ph?i h?p qu?c t?).

D?i n?n t?ng Win32, t?p l?n ?c duy tr? ch? y?u trong cc h?nh th?c c?a m?t 64-bit FILETIME c?u trc, ?i di?n cho s? l?ng 100-nanosecond cc kho?ng t? 1 thng m?t, 1601 UTC (th?i gian universal t?a ?).

Bi vi?t ny cho th?y lm th? no ? chuy?n ?i th?i gian UNIX ? ?nh d?ng th?i gian Win32 khc.

THNG TIN THM

Cc ch?c nng sau y chuy?n ?i m?t filetime trong cc ?nh d?ng time_t UNIX ? m?t Win32 FILETIME ?nh d?ng. Lu ? r?ng time_t l m?t gi tr? 32-bit v FILETIME m?t c?u trc 64-bit, do , cc ch?c nng Win32, Int32x32To64() ?c s? d?ng trong cc ch?c nng sau y:
   #include <winbase.h>
   #include <winnt.h>
   #include <time.h>

   void UnixTimeToFileTime(time_t t, LPFILETIME pft)
   {
     // Note that LONGLONG is a 64-bit value
     LONGLONG ll;

     ll = Int32x32To64(t, 10000000) + 116444736000000000;
     pft->dwLowDateTime = (DWORD)ll;
     pft->dwHighDateTime = ll >> 32;
   }
				
M?t khi th?i gian UNIX chuy?n ?i sang m?t c?u trc FILETIME, th?i gian Win32 khc ?nh d?ng c th? thu ?c m?t cch d? dng b?ng cch s? d?ng ch?c nng Win32 ch?ng h?n nh FileTimeToSystemTime() v FileTimeToDosDateTime().
   void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
   {
     FILETIME ft;

     UnixTimeToFileTime(t, &ft);
     FileTimeToSystemTime(&ft, pst);
   }
				

Thu?c tnh

ID c?a bi: 167296 - L?n xem xt sau cng: 19 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Win32 Application Programming Interface, khi ?c dng v?i:
    • Microsoft Windows 98 Standard Edition
    • Microsoft Windows Millennium Edition
T? kha:
kbdatetime kbhowto kbkernbase kbprogramming kbmt KB167296 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:167296

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com