1. 首先從官網下載boost庫,
http://nchc.dl.sourceforge.net/project/boost/boost/1.53.0/boost_1_53_0.7z只使用crc無需編譯boost,只需要包含指定的 crc.hpp即可。
2. 下載后解壓到d盤:D:\boost_1_53_0
3. 建立控制臺工程文件,并做如下設置:

4. 代碼如下
// crctest.cpp : 定義控制臺應用程序的入口點。
//

#include "stdafx.h"

#include <Windows.h>
#include <iostream>
#include <strstream>
#include <ostream>
#include <list>
#include <string>
#include <boost/crc.hpp>

using namespace std;
using namespace boost;


void _tmain(int argc, _TCHAR* argv[])


{
HANDLE hFile = ::CreateFile(_T("c:\\1.zip"), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(INVALID_HANDLE_VALUE == hFile)

{
cout << "文件不存在" << endl;
return ;
}

//存放到內存中
//取得文件大小(字節)
DWORD dwLen = GetFileSize(hFile, NULL);
char *readBuf = new char[dwLen];
memset(readBuf, 0, dwLen);

DWORD dwReadLen;
//將文件內容存放到 readBuf 中
ReadFile(hFile, readBuf, dwLen, &dwReadLen, NULL);

boost::crc_32_type result;
//計算一個字符的CRC值
//result.process_byte('a');
//計算字符串的CRC值
//result.process_bytes("abc", 3);
//計算文件的CRC值
result.process_block(readBuf, readBuf+dwLen*sizeof(char));

cout << std::hex << std::uppercase << result.checksum() << endl;

::CloseHandle(hFile);

delete []readBuf;

system("pause");
return;
} :