?????: FILETIME ?????? ?? ??? ????? ????

???? ?????? ???? ??????
???? ID: 188768 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

????? ?? ??? ?? ??????? ?????? ?? ??? ??? ?? ?? ?? ???? ????? ?? ?????, ????? ??? ??????, ?? ????? ???? ?? ??? ???? ?? ???????????? ???? ??? ???? ????? ?? ??? ?? ???? FILETIME ?????? ??? ???????? ??? ?? ?????? ??????? Win32 API ??? ?? ??? ????? ???? ???? ???

???? ???????

FILETIME ?????? 100-nanosecond ?????? ?? ?????? 1 ?????, 1601 ?? ??? ?????? ??? ?????? ?? 32-??? ??? ??? ?? ?? 64-??? ??? ??????? ?? ??? ??????? ?? ????? ??? ???? ???
   typedef struct _FILETIME {
     DWORD dwLowDateTime;
     DWORD dwHighDateTime;
   } FILETIME;
				
????? ??? ?? FILETIME ?????? 100-nanosecond ?????? ?? ?????? ??? ????? ?? ??? ?? ??? ????? ???? ??? ????? ?????? ?? ????????? ???? ?? ??? ?????? ??? ?????? ?? ???::
   #define _SECOND ((int64) 10000000)
   #define _MINUTE (60 * _SECOND)
   #define _HOUR   (60 * _MINUTE)
   #define _DAY    (24 * _HOUR)
				

????? ?? ??? ?? ??? Arithmetics ???? ?? ??? ??

?? ????? ??? ?? ???? ??????? ?????? ?? ???? ?? ??? ?????? ???? ??? ?????? ?? ???, ?? ???? ?? ???? ????? ??? ?? ?? ??? ????? 30 ????? ?????? ??? ???? ?? ??? ??? ?????? ?? ???? ????? ?? ???, ?? ?? ???????? ?? (?? 64-??? ????????), ?? quadword FILETIME ??? ?????? ???? ?? ??? ?????? ????, ?? ?? ??? FILETIME ?? ?????? ??? ?????? ?????

Assuming ft ?? ?? ????? ?? ??????? ?? ??? ???? FILETIME ?????? ??, ????? ????? ??? ?????? 30 ??? ?? ???:
   ULONGLONG qwResult;

   // Copy the time into a quadword.
   qwResult = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;

   // Add 30 days.
   qwResult += 30 * _DAY;

   // Copy the result back into the FILETIME structure.
   ft.dwLowDateTime  = (DWORD) (qwResult & 0xFFFFFFFF );
   ft.dwHighDateTime = (DWORD) (qwResult >> 32 );
				

?????? ???? ???

?? ???? ????? ?? ??? ????? ??? SetFileTime() ?????? ?? ????? ?? ??? ?? ???? ???
   BOOL SetFileTime(
     HANDLE hFile,                     // Handle to the file.
     CONST FILETIME *lpCreationTime,   // Time the file was created.
     CONST FILETIME *lpLastAccessTime, // Time the file was last accessed.
     CONST FILETIME *lpLastWriteTime   // Time the file was last
                                       // written to.
   );
				
?? ?????? ??????? ??????? ????? ??? ??????, ?? ????? ??? ???? ?? ??????? ?? ????? ?? ???? ????? ???? ??? ?? ?????? ?? ????? ?? ??? ???? ?? ????? ?? ???? ??? ???? ?? ??? ???? ?????? ?? ???? ????? CreateFile() ?? OpenFile() ???? ?? ??? ?? ??? ?? ??????? ?? ?? ???? ???? GENERIC_WRITE ????? ?? ??? ????? ???? ?? ???? ?????? ????? ??? ??? ?? ?? ??, ?? ??? ?? CloseHandle() ???? ?? ??? ?? ??? ?? ?????? ?? ???? ????? ?? ?????? ???? ??????

Assuming szFilename ?? ??? ????? ???? ??? ?? ft ?? ?? FILETIME ?????? ?? ???, ????? ????? ??? ??? ft ??? ????? ???? ?? ??? ????? ?? ??????? ?????? ??? ???? ??:
   BOOL bResult;
   HANDLE hFile = CreateFile( szFilename,
      GENERIC_WRITE, // The file must be opened with write access.
      FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );

   if (hFile != INVALID_HANDLE_VALUE) {
      bResult = SetFileTime( hFile, &ft, NULL, NULL );
      CloseHandle(hFile);
   }
				

????? ?? ??? ????????? ????

????? ?? ??? ?? ??????? ??????? ??? (UTC) ?? ?????? ??? UTC-?????? ??? loosely ????????? ?? ??????? ?????? ?? ??? ?? ??? ?? ??? ??? ????????, England ???? ????? ???? ???? ?? ?? ?? ??????? ??? (??????, ?????? ?? ??? ???? ??? ???? ?? ??? ??? ??) ?? respect ?? ??? ????? ??? ????????? ???? ?? ???? ??? ???? ?? ??? ????? ?? ???? ??? FileTimeToLocalFileTime() ???????????:
   BOOL FileTimeToLocalFileTime(
     CONST FILETIME *lpFileTime,  // Pointer to UTC file time to convert.
     LPFILETIME lpLocalFileTime   // Pointer to converted file time.
   );
????? ??? ?? ?? ?????? ????? ??????? ???????? ?????? ??? ??? ?? ??? ??? ?? ??? ??? ?????, ??? ?? ?????? ??? ??? ??, ?? ?? ?????? ????? ?????? ??? ??? ????, ??? ??? ?? ???? ??? ??? ?????? ?? ??? ??? ??? ???

????? ??? meaningful ????? ?? ????????? ??, ?? ???? ???? ??? ??????????? FileTimeToSystemTime() ?? ????? ?? ?????? ?????? ??? ?????? ???? ?? ???:
   BOOL FileTimeToSystemTime(
     CONST FILETIME *lpFileTime, // Pointer to file time to convert.
     LPSYSTEMTIME lpSystemTime   // Pointer to structure to receive
   );                            // system time.
				
SYSTEMTIME ?????? ?? ???, ???, ????, ?????? ?? ???, ????, ????, ????? ?? millisecond ?? ??? ???-??? ??????? ?? ????? ???? ??? ?? ?????? ?? ???????????? ???? ???

?? ?????? ?? ??? ????? ??????? ????? ?? ?????? ?????? ??? ?????? ?? ??? ?? ????????? ???? ?? ??? preferable ?? ??? ?? ?? ???? ??????????? GetDateFormat() ?? GetTimeFormat() ?? ????? ?? ???? ???:
   int GetDateFormat(
     LCID Locale,              // Locale for which date is to be formatted.
     DWORD dwFlags,            // Flags specifying function options.
     CONST SYSTEMTIME *lpDate, // Date to be formatted.
     LPCTSTR lpFormat,         // Date format string.
     LPTSTR lpDateStr,         // Buffer for storing formatted string.
     int cchDate               // Size of buffer.
   );

   int GetTimeFormat(
     LCID Locale,              // Locale for which time is to be formatted.
     DWORD dwFlags,            // Flags specifying function options.
     CONST SYSTEMTIME *lpTime, // Time to be formatted.
     LPCTSTR lpFormat,         // Time format string.
     LPTSTR lpTimeStr,         // Buffer for storing formatted string.
     int cchTime               // Size of buffer.
   );
				
??? ?? ??? ?? LOCALE_USER_DEFAULT ???? ???????? ?? ??? ??? ?? ??????? ???? ?? ???, ?????? ?? ????? ?? ????? passed ??????/??? ?? ?????? ??????? ??????? ?? ??????? ????? ?? ??? ???????? ???? ?? ???? ?? ?????? ???, lpFormat ???????? ?? ??? ?? ??????? ???? ?? ???? ????

Assuming ft ?? UTC ??? ???? FILETIME ?????? ??, ????? ????? ??? ???????? ft ??? ???????? ??????:
   SYSTEMTIME st;
   char szLocalDate[255], szLocalTime[255];

   FileTimeToLocalFileTime( &ft, &ft );
   FileTimeToSystemTime( &ft, &st );
   GetDateFormat( LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL,
     szLocalDate, 255 );
   GetTimeFormat( LOCALE_USER_DEFAULT, 0, &st, NULL, szLocalTime, 255 );
   printf( "%s %s\n", szLocalDate, szLocalTime );
				

???

???? ID: 188768 - ????? ???????: 03 ?????? 2010 - ??????: 4.0
???? ???? ???? ??:
  • Microsoft Win32 Application Programming Interface, ?? ???? ??? ?????? ???? ???:
    • Microsoft Windows 98 Standard Edition
    • Microsoft Windows Millennium Edition
??????: 
kbapi kbdatetime kbfileio kbinfo kbkernbase kbmt KB188768 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:188768

??????????? ???

 

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