`
xitongyunwei
  • 浏览: 926516 次
文章分类
社区版块
存档分类
最新评论

Compare two files are exactly the same

 
阅读更多

Usually our computers are attacked by viruses or other spyware website.

I don't know whetherthey modified files in our computer,especially execute files, or maybe HTML files.

Now, make a program to compare two files if they are exactly the same. I'd like use it to compare suspected file withe backup file.

Just wrote the code as below:


void CFileCompareDlg::OnBrowse()
{
// TODO: Add your control notification handler code here
CFileDialog filedlg(TRUE, NULL, NULL);
if(filedlg.DoModal() == IDOK)
{
m_fileName1 = filedlg.GetPathName();
}

UpdateData(FALSE);

}

void CFileCompareDlg::OnBrowse2()
{
// TODO: Add your control notification handler code here
CFileDialog filedlg(TRUE, NULL, NULL);
if(filedlg.DoModal() == IDOK)
{
m_fileName2 = filedlg.GetPathName();
}

UpdateData(FALSE);

}

void CFileCompareDlg::OnCompare()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_fileName1.Compare("")>0 && m_fileName2.Compare("")>0)
{
LPTSTR lpszFileName1 = new TCHAR[m_fileName1.GetLength()+1];
_tcscpy(lpszFileName1, m_fileName1);
CFile file1(lpszFileName1, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone);
ASSERT(file1);

LPTSTR lpszFileName2 = new TCHAR[m_fileName2.GetLength()+1];
_tcscpy(lpszFileName2, m_fileName2);
CFile file2(lpszFileName2, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone);
ASSERT(file2);

ULONGLONG ullFileLength1, ullFileLength2;
if((ullFileLength1=file1.GetLength()) != (ullFileLength2=file2.GetLength()))
{
MessageBox("The two files are not same length!");
return;
}

BYTE byte1, byte2;
ULONGLONG ullPos = 0;
while(ullFileLength1!=0)
{
file1.Read(&byte1, 1);
file2.Read(&byte2, 1);
ullPos ++;
if(byte1 != byte2)
{
char ch_Message[100];
sprintf(ch_Message, "The two files are not same at %d!", ullPos);
MessageBox(ch_Message);
return;
}
--ullFileLength1;
}
delete []lpszFileName1;
delete []lpszFileName2;

MessageBox("The two files are exactly the same!");
return;
}
else
{
MessageBox("Pls enter two files to be compared!");
return;
}

}

void CFileCompareDlg::OnExit()
{
// TODO: Add your control notification handler code here
CDialog::OnOK();
}

分享到:
评论

相关推荐

    Compare Files delphi_CompareFiles_

    compare files delphi binary

    P2P动态文件同步源代码及报告文档

    both of them will compare the lists of files they possess(assume that these shared files are stored in a designated folder in each peer), and proceed to exchange files so that they both have exactly ...

    compare the content of two worksheets

    VBA (Not tried) With the macro below it is possible to compare the content of two worksheets. The result is displayed in a new workbook listing all cell differences.

    MIEA-9.0_Candle_1.1.7_expertadvisor_

    MIEA v 9.0Entrance is based on candlestick and multi-currency analysis at the ... The remaining two (8 and 9) are directly related to the pair 1 and 2 so we compare their direction with exactly 1 and 2.

    compare file

    this is a programme that compare two files.

    lsa新旧比较.rar

    When multiple instances of the same LSA are received, a router determines which is the most recent by the following algorithm: Compare the sequence numbers. The LSA with the highest sequence number ...

    IDM.UltraCompare.Professional.v6.30.Incl.Keymaker-ZWT

    Text file compare features include binary and text compare of two or three text files at a time, with the ability to merge text differences between compared files. Folder compare supports comparison ...

    compare the file

    compare

    UE(官方下载)

    The selected text compare allows you to select portions of text between 2 files and execute a compare on ONLY the se Using the SSH/telnet console A tutorial for UltraEdit/UEStudio's SSH/telent ...

    Linqer compare SQL and LINQ files

    Linqer is a software application which can be used in order to compare SQL and LINQ files, as well as run them, and convert the first type of database to the other. This tool is portable, which means...

    string-compare-alignment.rar_We Two

    Test that we can compare two strings that are not 4-byte aligned.

    Spreadsheet Compare Files v1.36.0.zip

    Spreadsheet Compare Files v1.36.0.zip

    CompareObjects

    Class that allows comparison of two objects of the same type to each other. Supports classes, lists, arrays, dictionaries, child comparison and more.

    SQLDBDiffFreeware.3.5.1数据库对比

    With SQLDBDiff you cannot only compare two databases, but many databases to the same master database, you can save the list in XML file and avoid manual input. Ø Compare databases contents With ...

    Computation of the Fractional Fourier Transform

    We have compared two existing routines for the computation of the fast approximate fractional FouriertransformandoneroutineforthediscretefractionalFouriertransform.Westudiedindetail the dierent steps ...

    Compare用法Compare用法Compare用法

    Compare用法Compare用法Compare用法Compare用法Compare用法Compare用法

    Compare Two Lists v1.1官方版

    为您提供Compare Two Lists下载,Compare Two Lists是一个简单的文件比较工具,通过将你的列表复制并粘贴到程序中,然后比较相对应数据的差异,不需要通过表格函数来完成,操作相对比较简单。功能介绍 可以对单词或...

    Correlation

    compare two or more variables. Although frequently confused, they are quite different. Correlation measures the association between two variables and quantitates the strength of their relationship. ...

    微软内部资料-SQL性能优化5

    A clustered index is like a telephone directory in which all of the rows for customers with the same last name are clustered together in the same part of the book. Just as the organization of a ...

    Araxis Merge Professional 2012.4162 (x86/x64).part1

    Directly open and compare the text from Microsoft Office (Word and Excel), OpenDocument, PDF and RTF files. Compare images and binary files. Synchronize folders. Perform code reviews and audits. Work...

Global site tag (gtag.js) - Google Analytics