tw0912.pp 783 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const
  2. BufSize = 2048;
  3. var
  4. f : file;
  5. res : longint;
  6. buf : array [0..BufSize-1] of byte;
  7. result : word;
  8. begin
  9. assign(f,paramstr(0));
  10. {$I-}
  11. reset(f,1);
  12. res:=IOResult;
  13. {$I+}
  14. if res=0 then
  15. Writeln('It is possible to open the executable in Read/Write mode')
  16. else
  17. begin
  18. filemode:=0;
  19. {$I-}
  20. reset(f,1);
  21. res:=IOResult;
  22. {$I+}
  23. if res=0 then
  24. Writeln('It is only possible to open the executable in Read mode')
  25. else
  26. Writeln('It is not possible to open the executable in Read mode');
  27. end;
  28. if res=0 then
  29. begin
  30. {$I-}
  31. blockread(f,buf,sizeof(buf),result);
  32. res:=IOResult;
  33. {$I+}
  34. if res<>0 then
  35. Writeln('Problem reading executable');
  36. if res=0 then
  37. close(f)
  38. else
  39. RunError(res);
  40. end
  41. else
  42. RunError(res);
  43. end.