=====> 怎样比较两个文件的版本???

cd7809 2002-12-01 08:17:16

我在copy文件之前想比较一下两个文件的版本, 只有源文件版本高的时候才copy, 不知怎么处理, 非常感谢!!
...全文
83 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Rigel 2002-12-01
  • 打赏
  • 举报
回复
BOOL GetFileInformationByHandle(
HANDLE hFile, // handle to file
LPBY_HANDLE_FILE_INFORMATION lpFileInformation // buffer
);
TrueDexter 2002-12-01
  • 打赏
  • 举报
回复
如果是DLL的话可以用API:
是 GetDllVersion 或 GetFileVersion 之类的名字,你查一查吧.
cbc 2002-12-01
  • 打赏
  • 举报
回复
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 Value

TRUE if the status information for the specified file is successfully obtained; otherwise, FALSE.

Parameters

rStatus

A 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.
lpszFileName

A 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.

Remarks

The 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
}

zhangyilan 2002-12-01
  • 打赏
  • 举报
回复
不知道一般的文件属性中是否有版本一项
关注

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧