检测dll是32/64位 ?
void CCheck32Or64Dlg::OnButton2() { CString fileName = ""; CFileDialog *fileDialog = new CFileDialog(TRUE,NULL,NULL,OFN_HIDEREADONLY,"Dll Files(*.dll)|*.dll|Exe Files(*.exe)|*.exe||",NULL); if(fileDialog->DoModal()==IDOK) { fileName = fileDialog->GetPathName(); byte buf[4]; CFile file(fileName,CFile::modeRead); file.Seek(0x40-4,0); file.Read(buf,4); int a,b,c,d; a = int(buf[0]); b = int(buf[1])*256; c = int(buf[2])*256*256; d = int(buf[3])*256*256*256; int sum = a+b+c+d; file.Seek(sum+4,0); byte bufMachine[2]; file.Read(bufMachine,2); int machine = (int)bufMachine[0] + (int)(bufMachine[1])*256; if(machine == 0x14C) { MessageBox(fileDialog->GetFileName()+"是32位PE文件","检测结果"); } else if(machine == 0x8664) { MessageBox(fileDialog->GetFileName()+"是64位PE文件","检测结果"); } else { MessageBox("未能识别:"+fileDialog->GetFileName()+"多少位的PE文件!","检测结果"); } } }
版权声明:本文为博主原创文章,未经博主允许不得转载。