Легко, держи:
| Код |
function IsWin32(Path: pChar): boolean; var idh: PImageDosHeader; inh: PImageNtHeaders; hFile, BytesReaded: dword; Buffer: array [0..512] of Byte; begin Result := False; hFile := CreateFile(Path, GENERIC_READ , FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0); if ReadFile(hFile, Buffer, 512, BytesReaded, 0) then begin idh := @Buffer; if idh^.e_magic = IMAGE_DOS_SIGNATURE then begin inh := pointer(dword(@Buffer) + idh^._lfanew); if inh^.Signature = IMAGE_NT_SIGNATURE then Result := True; end; end; CloseHandle(hFile); end;
procedure TForm1.FormCreate(Sender: TObject); begin if IsWin32('C:\Program Files\Asm\resrebld.EXE') then ShowMessage('This file is Win32 application') else ShowMessage('This file is not Win32 application') end;
|
|