开发者

Problem with UpdateResource (Out of memory)

I use this code to attach a file as a resource to an executable file :

interface
type
  TBuffer = Array [0 .. 0] of Byte;
  PBuffer = ^TBuffer;

Procedure AttachFile();
var
  DataLength: DWord;
  Data: PBuffer;
begin
  FS := TFileStream.Create(Filename, fmOpenRead);
  try
    FS.Seek(0, soFromBeginning);
    DataLength := FS.Size;
    GetMem(Data, DataLength);
    FS.Read(Data^, Data开发者_如何学PythonLength);
  finally
      FS.Free;
  end;
  UpdateResource(ResourceHandle, RT_RCDATA, pchar('ResName'),
    0, Data, DataLength);
  EndUpdateResource(ResourceHandle, false);
end;

The problem is that when i want to attach a Larg (1GB for example) file using this code, I'll receive this error : Out of memory.

I also tried to split my file to smaller parts(for example : 100MB) and attach it using a for ring but it still doesn't work and i receive Out of memory


Embedded resources aren't meant to be this big and you are apparently hitting the limits.

You should deliver this file as a standalone file alongside your executable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜