把配置的内容加到exe文件的最后面,不会影响exe的执行
例如,程序名未my.exe:
type
myconfig = record
.....//any thing you want
end;
生产带配置的my.exe
var
fs, ds:TFileStream
conf:myconfig
begin
fs := TFileStream.Create('my.exe', fmOpenRead or fmShareDenyNone);
ds := TFileStream.Create('newmy.exe', fmCreate);
ds.copyfrom(fs, 0);
ds.write(conf, sizeof(conf));
fs.free;
ds.free;
end;
在newmy.exe里读取config
var
conf: myconfig;
fs: TFileStream;
begin
fs := TFileStream.create(paramstr(0), fmOpenRead or fmShareDenyNone);
fs.position := fs.size - sizeof(conf);
fs.read(conf, sizeof(conf));
fs.free;
end;