filetime.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 1k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "filetime.h"
  4. //-----------------------------------------------------------------------------
  5. // class FileTime
  6. //-----------------------------------------------------------------------------
  7. //
  8. // Format the filetime numeric value to a text string.
  9. // Uses the same format as the shell's defview.
  10. //
  11. void FileTime::GetString(
  12.     CString *pstr
  13.     ) const
  14. {
  15.     DBGASSERT((NULL != pstr));
  16.     SYSTEMTIME st;
  17.     //
  18.     // This code matches the shell's date/time display format.
  19.     //
  20.     if (FileTimeToSystemTime(&m_time, &st))
  21.     {
  22.         int cchBuf = 40;
  23.         LPTSTR pszBuf = pstr->GetBuffer(40);
  24.         int cch = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, pszBuf, cchBuf);
  25.         cchBuf -= cch;
  26.         pszBuf += cch - 1;
  27.         *pszBuf++ = TEXT(' ');
  28.         *pszBuf = 0;          // (in case GetTimeFormat doesn't add anything)
  29.         cchBuf--;
  30.         GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, pszBuf, cchBuf);
  31.         pstr->ReleaseBuffer();
  32.     }
  33.     else
  34.     {
  35.         DBGERROR((TEXT("FileTimeToSystemTime failed with error 0x%08X.ntLODWORD: 0x%08X, HIDWORD: 0x%08X"), 
  36.                  GetLastError(), m_time.dwLowDateTime, m_time.dwHighDateTime));
  37.     }
  38. }