Extract a resource to file


/ Published in: Delphi
Save to your folder(s)



Copy this code and paste it in your HTML
  1. procedure ExtractResource(ResourceName, FileName: string);
  2. begin
  3. ExtractResource(hInstance, ResourceName, Filename);
  4. end;
  5. procedure ExtractResource(hnd: Cardinal; ResourceName, FileName: string);
  6. var
  7. rStream: TResourceStream;
  8. fStream: TFileStream;
  9. begin
  10. if FindResource(hnd, PChar(ResourceName), RT_RCDATA) <> 0 then
  11. begin
  12. rStream := TResourceStream.Create
  13. (hnd, ResourceName, RT_RCDATA);
  14. try
  15. fStream := TFileStream.Create(FileName, fmCreate);
  16. try
  17. fStream.CopyFrom(rStream, 0);
  18. finally
  19. fStream.Free;
  20. end;
  21. finally
  22. rStream.Free;
  23. end;
  24. end;
  25. end;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.