其实,install.exe对自己进行读操作很简单.
这里有一个例子,稍加修改就可以形成install.exe
源代码:
unit unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Read1: TButton;
Memo1: TMemo;
procedure Read1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Read1Click(Sender: TObject);
var
f:file of char;
size:longint;
p,i:integer;
s:string;
c:char;
begin
assignfile(f,application.ExeName);
{取得运行文件本身的名字}
s := '';
p := 10;
filemode := 0;
{将文件操作模式设为只读}
reset(f);
{建立关联,在这里,编译器不会报错,因为已经设了只读模式}
size := filesize(f);
seek(f,size-p);
{将读指针定位在倒数10字节的位置}
for i := 1 to p do
begin
read(f,c);
if (byte(c) < 32) or (byte(c) > 126) then c := '.';
s := s + c;
end;
memo1.Lines.Add(s);
closefile(f);
end;
end.
当然,为了配合这个程序,我另外写了一个程序,在这个程序的
末尾加入10个字节.(可以向我索取,很简单的)
还有问题,欢迎来信讨论! mophy@188.net