DisplayFileInfo--文件信息

BOOL CAudioboxDlg::DisplayFileInfo(LPTSTR szFile) {
    HANDLE hFile;
    LONGLONG llSize=0;
    DWORD dwSizeLow=0, dwSizeHigh=0;
    TCHAR szScrap[64]; // Open the specified file to read size and date information     hFile = CreateFile(szFile,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING, (DWORD) 0, NULL); if (hFile == INVALID_HANDLE_VALUE) {
        RetailOutput(TEXT("*** Failed(0x%x) to open file (to read size)!/r/n"),
                     GetLastError()); return FALSE; }

	
    dwSizeLow = GetFileSize(hFile, &dwSizeHigh); if ((dwSizeLow == 0xFFFFFFFF) && (GetLastError() != NO_ERROR)) {
        RetailOutput(TEXT("*** Error(0x%x) reading file size!/r/n"),
                     GetLastError());
        CloseHandle(hFile); return FALSE; } // Large files will also use the upper DWORD to report size. // Add them together for the true size if necessary.  if (dwSizeHigh)
        llSize = (dwSizeHigh << 16) + dwSizeLow; else
        llSize = dwSizeLow; // Read date information     BY_HANDLE_FILE_INFORMATION fi; if (GetFileInformationByHandle(hFile, &fi)) {
        CTime time(fi.ftLastWriteTime);

        wsprintf(szScrap, TEXT("File date: %02d/%02d/%d/0"), 
                 time.GetMonth(), time.GetDay(), time.GetYear());
        m_StrFileDate.SetWindowText(szScrap); }

    CloseHandle(hFile); // Update size/date windows     wsprintf(szScrap, TEXT("Size: %d bytes/0"), dwSizeLow);
    m_StrFileSize.SetWindowText(szScrap); return TRUE; }

你可能感兴趣的:(Date,windows,File,report,null)