Extract the file from the resources and save to the specified path.
1 2 3 4 5 6 7 |
var resName, resNewName: string; begin resName:= 'txtFile'; resNewName:= 'C:\txtFile.txt'; extractRes(resName, resNewName); end; |
Options
resName - resource name
resNewName - path to save the file
Result
True if the operation is successful, False if not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function extractRes (ResName, ResNewName: string): Boolean; var res: TResourceStream; begin Result := False; if FindResource(0, PChar(ResName), RT_RCDATA) = 0 then Exit; try res := TResourceStream.Create(Hinstance, Resname, RT_RCDATA); res.Position := 0; res.SavetoFile(ResNewName); Result := True; finally res.Free; end; end; |