INFO: ??????? ?? ???? FILETIME

?????? ????????? ?????? ?????????
???? ???????: 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 ????? ??????. ?????? ??????? ??? ??? ??? ???? ????? ?????? ?? FILETIME ??? quadword (64-?? ?????) ? ????? ?? ?????? ?? ?? ?????? ?????? ??? FILETIME.

??? ??? ??? ???? 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().

szFilename assuming ??? ??? ???? ??? ???? FILETIME ? ????? ????????? ???????? ?????? ??? ????? ????? ????? ????? ??? ????? ?? ???:
   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);
   }
				

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

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

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

??? ????? ???? ??? ??????? ?????? ?? ????? ?????? ?? ????????? ??????? ??????? ?????? ?? ??????. ????? ?????? ???? ???????? 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 ?????? ????? ??? ??? ??????? ? ???? ???????? ?????? ???? ?? ??????? ???????/????? ???????? ??? ??????? ????????? ????????? ??????? ???????. ?? ??? ??????? ????? ????? NULL ???????? lpFormat.

??? ??? ??? ???? FILETIME ????? ??? ???? UTC ? ????? ????? ????????? ???????? ?????? ????? ??????? ?? ???:
   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 );
				

???????

???? ???????: 188768 - ????? ??? ??????: 04/????/1428 - ??????: 3.3
????? ???
  • Microsoft Win32 ????? ????? ???????, ????? ?????? ??:
    • Microsoft Windows 95
    • Microsoft Windows 98 Standard Edition
    • Microsoft Windows Millennium Edition
    • Microsoft Windows NT 4.0
    • Microsoft Windows NT 3.51 Service Pack 5
    • Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000
    • the operating system: Microsoft Windows XP
????? ??????: 
kbmt kbapi kbdatetime kbfileio kbinfo kbkernbase KB188768 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????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