void Cnew_test_06_04Dlg::OnBnClickedBt() { CString szFilter = L"*.exe|*.*||"; CFileDialog fd(TRUE,L"*", L"*.exe", OFN_HIDEREADONLY, szFilter, this); if(fd.DoModal() == IDOK) { CString szFileName = fd.GetPathName();//取得開啟檔案全名(包含路徑) // fopen(szFileName); CFile File; char *buf; buf = new char [256]; DWORD dwFileLen=0; if (File.Open(szFileName,CFile::modeRead |CFile::typeBinary)){ File.SeekToBegin(); File.Read(buf, 256); } CString csOutput; while(csOutput.Format !=NULL) { IDC_EDIT1.AddString(IDC_EDIT1.GetItemText(IDC_EDIT1)); buf=IDC_EDIT.GetNext(); } //csOutput.Format(L"0x%02x 0x%02x 0x%02x", buf[0], buf[1],buf[2]); // int buf=0 // int i=0 //GetDlgItem(IDC_EDIT1)->SetWindowText(csOutput); delete [] buf; }
<pre lang="c++">CString csOutput; //csOutput.Format(L"0x%02x 0x%02x 0x%02x 0x%02x", buf[0], buf[1],buf[2],buf[3]); //GetDlgItem(IDC_EDIT1)->SetWindowText(csOutput); buffcount=File.Read(buf, 256); for(int i=0;i<buffcount;i++)> { cstring temp; temp.format(L"0x%02x",buf[i]); csoutput+=temp; } delete [] buf; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)