// Vs2005 and vc6 are compiled and approved. The CRC verification function and related content are found online and changed slightly, call example for writing a verification file </P> <p> # include <windows. h> </P> <p> # define crc32_polynomial 0xedb88320 </P> <p> unsigned long tablecrc32 [256]; </P> <p> void initializetablecrc32 (); <br/> unsigned long getcrc32 (ptchar buffer, unsigned long length); <br/> unsigned long getfilecrc32 (const ptchar szfilename ); </P> <p> int winapi winmain (hinstance, hinstance hprevinstance, ptchar SZ Cmdline, int icmdshow) <br/>{< br/> tchar sztemp [256]; <br/> initializetablecrc32 (); </P> <p> wsprintf (sztemp, text ("% 08x"), getfilecrc32 (text (". // test file .txt "); <br/> MessageBox (null, sztemp, text (" title "), 0 ); <br/>}</P> <p> void initializetablecrc32 () <br/> {<br/> int I, j; <br/> unsigned long H = 1; <br/> tablecrc32 [0] = 0; <br/> for (I = 128; I >>= 1) <br/>{< br/> H = (h> 1) ^ (H & 1 )? Crc32_polynomial: 0); <br/> for (j = 0; j <256; j + = 2 * I) <br/>{< br/> tablecrc32 [I + J] = tablecrc32 [J] ^ h; <br/>}</P> <p> unsigned long getcrc32 (char * buffer, unsigned long length) <br/> {<br/> unsigned long CRC; <br/> CRC = 0 xffffffff; <br/> while (length --) <br/>{< br/> CRC = (CRC> 8) ^ tablecrc32 [(CRC ^ * buffer ++) & 0xff]; <br/>}< br/> return CRC ^ 0 xffffffff; <br/>}</ P> <p> unsigned long getfilecrc32 (const ptchar szfilename) <br/>{< br/> handle hfile; <br/> char * buffer; <br/> unsigned long length, bytesreadwrite, CRC; </P> <p> hfile = createfile (szfilename, generic_read, file_share_read, null, open_existing, file_attribute_normal, null ); // open the file <br/> If (hfile = invalid_handle_value) <br/>{< br/> return-1; <br/>}< br/> length = getfilesize (hfile, null); <br/> buffer = (char *) V Irtualalloc (null, length, mem_reserve | mem_commit, page_execute_readwrite); <br/> If (! Readfile (hfile, buffer, length, & bytesreadwrite, null) <br/>{< br/> return-1; <br/>}< br/> closehandle (hfile); // close the file <br/> CRC = getcrc32 (buffer, length); <br/> virtualfree (buffer, 0, mem_release); </P> <p> return CRC; <br/>}