I am using delphi 3.02
If have created a resource file that contains a binary file (in this case a dbf file) when I try to extract the file, it appears to be truncated after the first byte that contains hex 00 (ie null). Can you only extract text files from resource files? If not how do you extract a binary file from a resource.
Below is my code for extracting the file from the resource: (note this works fine for a plain ascii text file)
stream : tmemeroystream;
stream := tMemoryStream.create;
// test.dbf in truncated after the first null byte (ie Hex 00)
procedure GetRes(ResID : String; var Mems :Tmemorystream);
FndRes : HRSRC;
LdRes : THandle;
Buffer : PChar;
//Locates the resource and returns a handle to it.
// If the function fails it returns 0.
FndRes := FindResource(HInstance,
if FndRes <> 0 then
//Loads the resource into global memory and returns a handle to //the global memory block containing the data associated with the //resource. If this function fails it also returns 0.
LdRes := LoadResource(Hinstance,
if LdRes <> 0 then
//If the loaded resource is locked, the return value is a
// pointer to the first byte of the resource otherwise, it is
Buffer := LockResource(LdRes);
// To make this a valid PChar, you should add a null at the
// end of the buffer, but this demo works without error as far
// as I know.
//Important, must set the stream position to the first byte //of data. Will not work without this.
mems.Position := 0;