W
wp231957
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure fileisexe(filename:string);stdcall;<br>var<br> readbufferchar;<br> numberofbytesrw:dword;<br> HFILE:thandle;<br>label openfileerr;<br>label fileisnotexe;<br>label filenotpe;<br>label filemaybedll;<br>label exita;<br>begin<br> hfile:=createfile(pchar(filename),GENERIC_READ AND GENERIC_WRITE,FILE_SHARE_READ,nil,3,FILE_ATTRIBUTE_NORMAL,0);<br> if hfile=invalid_handle_value then goto openfileerr;<br> setfilepointer(hfile,0,nil,file_begin);<br> getmem(readbuffer,2);<br> readfile(hfile,readbuffer^,2,numberofbytesrw,nil);<br> showmessage(readbuffer); //请问,我这里为什么SHOW的是乱码呢,想像中应该是MZ才对啊,取PE文件的头2个字节<br> freemem(readbuffer);<br> goto exita;<br>openfileerr:<br> showmessage(filename+' open error!');<br> goto exita;<br>fileisnotexe:<br> showmessage(filename+' is not a exe file');<br> goto exita;<br>filenotpe:<br> showmessage(filename+' is not a pe file');<br> goto exita;<br>filemaybedll:<br> showmessage(filename+' may be a dll file');<br> goto exita;<br>exita:<br>end;