-
Notifications
You must be signed in to change notification settings - Fork 9
/
CRC_32.h
68 lines (54 loc) · 2.21 KB
/
CRC_32.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/****************************************************************************
CRC_32.h : header file for the CRC_32 class
written by PJ Arends
pja@telus.net
based on the CRC-32 code found at
http://www.createwindow.com/programming/crc32/crcfile.htm
For updates check http://www3.telus.net/pja/crc32.htm
-----------------------------------------------------------------------------
This code is provided as is, with no warranty as to it's suitability or usefulness
in any application in which it may be used. This code has not been tested for
UNICODE builds, nor has it been tested on a network ( with UNC paths ).
This code may be used in any way you desire. This file may be redistributed by any
means as long as it is not sold for profit, and providing that this notice and the
authors name are included.
If any bugs are found and fixed, a note to the author explaining the problem and
fix would be nice.
-----------------------------------------------------------------------------
****************************************************************************/
#ifndef _CRC_32_H_EA6C0EE0_BC30_11d5_B625_A58C4DF45B22_INCLUDED
#define _CRC_32_H_EA6C0EE0_BC30_11d5_B625_A58C4DF45B22_INCLUDED
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef _WINDOWS_
#include <windows.h>
#endif // _WINDOWS_
#define WM_CRC_THREAD_DONE WM_APP + 0x2DB1
class CRC_32
{
typedef struct tag_CRCStruct
{
CRC_32 *pCRC_32;
TCHAR FileName[_MAX_PATH];
LPBYTE pByte;
UINT size;
HWND hWnd;
HANDLE Thread;
} CRCStruct, *LPCRCStruct;
public:
CRC_32();
DWORD CalcCRC(LPCTSTR FileName, HWND ProgressWnd = NULL);
DWORD CalcCRC(LPVOID buffer, UINT size, HWND ProgressWnd = NULL);
private:
static DWORD WINAPI CRC32ThreadProc(LPVOID lpVoid);
void Calculate (const LPBYTE buffer, UINT size, ULONG &crc);
ULONG Reflect(ULONG ref, char ch);
ULONG Table[256];
};
#endif // _CRC_32_H_EA6C0EE0_BC30_11d5_B625_A58C4DF45B22_INCLUDED
/////////////////////////////////////////////////////////////////////////////
//
// End of CRC_32.h
//
/////////////////////////////////////////////////////////////////////////////