Open the file by opening the button and move it through the left key to open the file and calculate the CRC

Source: Internet
Author: User

Tag: false Code None Temp Data Control cat Filter Sage

We have the learn open a file by using an Open button, this is code below:

1 voidCfilecrcdlg::onopen ()2 {3     //Todo:add your control notification handler code here4 WORD N;5 WORD i;6BYTE szchar[201];7BYTE crc_hex[4],BT;8CString strtemp="";9 CFileDialog Filedlg (TRUE);TenFiledlg.m_ofn.lpstrfilter="All files (*. *)"; One     if(Filedlg.domodal () = =IDOK) A     { - CFile file (filedlg.m_ofn.lpstrfile,cfile::moderead); - UpdateData (TRUE); theM_path + =file. GetFilePath (); -M_path + ="\ r \ n"; -         //clear the Edit Dlg -I=0xFFFF; +memset (Szchar,0,201); -          while(file. Read (Szchar, $)) +         { An=0; at              while(Szchar[n]) -             { -I=crc_16 (I,szchar[n]); -n++; -             } -memset (Szchar,0,201); in         } -strtemp. Format ("%d", i); tom_crc_dec+=strtemp; +m_crc_dec+="\ r \ n"; -          the Swap_word_byte (i,crc_hex); *          for(i=0;i<4; i++) $         {Panax NotoginsengBT =* (Char*) (crc_hex+i); -strtemp. Format ("%c", BT); them_crc_hex+=strtemp; +         } AM_crc_hex + ="\ r \ n"; the file. Close (); + UpdateData (FALSE); -     } $}
void Cfilecrcdlg::onopen ()

Now, we is going to using another-to-open a file and get the CRC check sum.

Here is the code:

1 voidcfilecrcdlg::ondropfiles (hdrop hdropinfo)2 {3     //todo:add your message handler code here and/or call default4 UINT J,ifilecount;5     CharFile_name[max_path];6     //Variable for CRC7 WORD N;8 WORD i;9BYTE szchar[201];TenBYTE crc_hex[4],BT; OneCString strtemp=""; A  -Ifilecount=::D ragqueryfile (Hdropinfo,0xFFFFFFFFNull0); -      the      for(j=0; j<ifilecount;j++) -     { - ::D ragqueryfile (Hdropinfo,j,file_name,max_path); - CFile file (file_name,cfile::moderead); + UpdateData (TRUE); -M_path + =file. GetFilePath (); +M_path + ="\ r \ n"; A         //clear the Edit Dlg atI=0xFFFF; -memset (Szchar,0,201); -          while(file. Read (Szchar, $)) -         { -n=0; -              while(Szchar[n]) in             { -I=crc_16 (I,szchar[n]); ton++; +             } -memset (Szchar,0,201); the         } *strtemp. Format ("%d", i); $m_crc_dec+=strtemp;Panax Notoginsengm_crc_dec+="\ r \ n"; -          the Swap_word_byte (i,crc_hex); +          for(i=0;i<4; i++) A         { theBT =* (Char*) (crc_hex+i); +strtemp. Format ("%c", BT); -m_crc_hex+=strtemp; $         } $M_crc_hex + ="\ r \ n"; - file. Close (); - UpdateData (FALSE); the     } - ::D ragfinish (hdropinfo);Wuyi cdialog::ondropfiles (hdropinfo); the}
void Cfilecrcdlg::ondropfiles (Hdrop hdropinfo)

OK, Enjoy. Thank you!

B.R.

Open the file by opening the button and move it through the left key to open the file and calculate the CRC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.