求助:获得文件的版本信息,最好有源代码

解决方案 »

  1.   


    struct fDinfo                      //目录信息;
    {
    char directory_name[128]; //目录名称; //ok
    char path_name[128]; //目录存放路径;//ok
    long directory_size; //目录大小;
    char create_time[64]; //创建目录日期;  //ok
    char owner_name[64]; //目录拥有者;
    char directory_desc[128]; //目录描述;
    short directory_attribute; //目录属性() 用三位数表示, //ok
    //如”111”表示具备“只读、隐藏、存档”属性
    //”000”表示不具备“只读、隐藏、存档”属性
    char            directory_share[20]; //目录共享名称,若为空,表示没共享;
    };
    //函数描述:函数名Fget_directoryinfo
    //功能:取指定目录下的目录信息
    //参数描述:    *fdirectoryPath  为指定的的目录或盘符
    // directory_array[MAX1]存放取得的目录信息的数组,
    // length为数组实际存放项的长度
    //返回值描述:返回值1表示正常,-1表示出错
    short Fget_directoryinfo( char *fdirectoryPath, fDinfo directory_array[MAX1],int& length )
    {
    fDinfo dirInfo;
    memset( &dirInfo, 0, sizeof( fDinfo ) ); WIN32_FIND_DATA data; //is FindFirstFile Parameters
    HANDLE hFind;
    int nCount=0; //
    char filename[256];
    memset( filename, 0, 256 );
    strcpy( filename, fdirectoryPath );
    strcat( filename, "\\" ); //查找当前目录下的所有文件
    hFind = FindFirstFile( filename, &data );
    while( hFind != INVALID_HANDLE_VALUE )
    {
            // for directories, count all files there
    if( ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) != 0 )
    {
    FILETIME ftLocal;
    SYSTEMTIME stCreate;
    // Convert the last-write time to local time.
    if( !FileTimeToLocalFileTime( &data.ftCreationTime, &ftLocal ) )
    {
    return -1;
    }
    // Convert the local file time from UTC to system time.
    FileTimeToSystemTime( &ftLocal, &stCreate ); wsprintf( dirInfo.create_time, "%02d/%02d/%d  %02d:%02d",
    stCreate.wDay, stCreate.wMonth, stCreate.wYear,
    stCreate.wHour, stCreate.wMinute ); //时间

    //大小
    strcpy( dirInfo.directory_name, data.cFileName ); // 目录名称
    strcpy( dirInfo.path_name, fdirectoryPath ); //目录存放路径 strcat( filename, data.cFileName );
    DWORD dwAttrib = GetFileAttributes( filename );
    if( dwAttrib & FILE_ATTRIBUTE_READONLY ) //100
    {
    if( dwAttrib & FILE_ATTRIBUTE_ARCHIVE ) //110
    {
    if( dwAttrib & FILE_ATTRIBUTE_HIDDEN ) //111
    {
    dwAttrib = 111;
    }
    else //110
    {
    dwAttrib = 110;
    }
    }
    else
    {
    if( dwAttrib & FILE_ATTRIBUTE_HIDDEN ) //101
    {
    dwAttrib = 101;
    }
    else //100
    {
    dwAttrib = 100;
    }
    }
    }
    else
    {
    if( dwAttrib & FILE_ATTRIBUTE_ARCHIVE ) //010
    {
    if( dwAttrib & FILE_ATTRIBUTE_HIDDEN ) //011
    {
    dwAttrib = 011;
    }
    else //010
    {
    dwAttrib = 010;
    }
    }
    else
    {
    if( dwAttrib & FILE_ATTRIBUTE_HIDDEN ) //001
    {
    dwAttrib = 001;
    }
    else //000
    {
    dwAttrib = 000;
    }
    }
    }
    dirInfo.directory_attribute = dwAttrib; //目录属性 // get folder share name...
    memcpy( &directory_array[nCount], &dirInfo, sizeof( fDinfo ) );
    nCount++;
    } if( !FindNextFile(hFind, &data) ) // continue  find next dir
    {
    CloseHandle( hFind );
    hFind = INVALID_HANDLE_VALUE;
    }
    } length=nCount;
    return 1;
    }
      

  2.   

    QuickTimeDlg.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoA@16
    QuickTimeDlg.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoSizeA@8这个错误怎么改
      

  3.   

    没有加 #include <stdafx.h>
    试试!
    goog luck
      

  4.   

    本来就有这个的#include "stdafx.h"。我想不是这个原因
      

  5.   

    把这个库加上看看, Version.lib
      

  6.   

    http://www.codeguru.com/files/FileVersionInfo.html
      

  7.   

    CString strPath="C:\\hello.txt";
    CFile file;
    file.Open(strPath,CFile::modeRead);
    CFileStatus fstatus;
    file.GetStatus(strPath,fstatus)
    CFile::GetStatus 
    BOOL GetStatus( CFileStatus& rStatus ) const;static BOOL PASCAL GetStatus( LPCTSTR lpszFileName, CFileStatus& rStatus );Return ValueTRUE if the status information for the specified file is successfully obtained; otherwise, FALSE. ParametersrStatusA reference to a user-supplied CFileStatus structure that will receive the status information. The CFileStatus structure has the following fields: CTime m_ctime   The date and time the file was created.
    CTime m_mtime   The date and time the file was last modified.
    CTime m_atime   The date and time the file was last accessed for reading.
    LONG m_size   The logical size of the file in bytes, as reported by the DIR command.
    BYTE m_attribute   The attribute byte of the file.
    char m_szFullName[_MAX_PATH]   The absolute filename in the Windows character set. 
    lpszFileNameA string in the Windows character set that is the path to the desired file. The path can be relative or absolute, but cannot contain a network name.ResThe virtual version of GetStatus retrieves the status of the open file associated with this CFile object. It does not insert a value into the m_szFullName structure member.The static version gets the status of the named file and copies the filename to m_szFullName. This function obtains the file status from the directory entry without actually opening the file. It is useful for testing the existence and access rights of a file.The m_attribute is the file attribute. The Microsoft Foundation classes provide an enum type attribute so that you can specify attributes symbolically:enum Attribute {
       normal =    0x00,
       readOnly =  0x01,
       hidden =    0x02,
       system =    0x04,
       volume =    0x08,
       directory = 0x10,
       archive =   0x20
       };Example//example for CFile::GetStatus
    CFileStatus status;
    extern CFile cfile;
    if( cfile.GetStatus( status ) )    // virtual member function
       {
          #ifdef _DEBUG
             afxDump << "File size = " << status.m_size << "\n";
          #endif
       }
    char* pFileName = "test.dat";
    if( CFile::GetStatus( pFileName, status ) )   // static function
       {
          #ifdef _DEBUG
             afxDump << "Full file name = " << status.m_szFullName << "\n";
          #endif
       }CFile Overview | 
      

  8.   

    加上Version.lib后好用了,谢谢大家