我在EXE文件尾部追加一些数据,在EXE运行时想把这些数据读出来,Delphi不能自己打开自己,请问一下怎么记取?

解决方案 »

  1.   

    你会不会程序调用别的程序 会的话打开自己也是一样的 shellexecuteuse shellapi
      

  2.   

    http://www.delphibox.com/article.asp?articleid=422还是先看下windows  pe文件格式
    修改 可以通过很多方式的\最终都是 映射成硬盘的文件
      

  3.   

    读取是容易,,master delphi7 就有demoprocedure TForm1.FormCreate(Sender: TObject);
    var
      nSize: Integer;
      hFile: THandle;
      strSize: String;begin
      hFile := CreateFile (PChar (ParamStr (0)),
        0, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
      nSize := GetFileSize (hFile, nil);
      CloseHandle (hFile);  SetLength (strSize, 20);
      Str (nSize, strSize);  Caption := 'Size = ' + strSize;
    end;createfile打开,再read 即可;但是写到入exe文件中,需要点技巧顶~~~vividw(vividw) ~~~
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      fs:TFileStream;
      strBuf:array[0..501] of char;
    begin
      fs:=TFileStream.Create(Application.ExeName,fmOpenRead);    //创建一个文件流对象
      try
        fs.Position:=1000;                  //将文件流对象指针指到1000的位置
        fs.ReadBuffer(strBuf,500);          //读取长度为500的这一段内容
        showmessage(strBuf);
      finally
        fs.Free;
      end;
    end;主要思想应该都是这些了,其他的你可以自己再改造一下。
      

  5.   

    刚好前几天写了这个..不过我不是这样的..写入就不说了,太简单了..读取是COPY自身到TEMP目录..再已文本读取..指向尾部..反向读取100个再CenterCat(string,'start:',':end')..
      

  6.   

    用 TFileStream 就可以打开。模式: fmOpenRead + fmShareDenyNone