Extract resource file

I attached the resource file to an existing exe file using the UpdateResource function.

How can I extract it?

Edit

This is my code for attaching a resource file to an existing exe file:

 Uses Classes, Windows, SysUtils, Dialogs; Type TBuffer = Array[0..0] of Byte; PBuffer = ^TBuffer; Var FS : TFileStream; ResourceHandle : THandle; DataLength : DWord; Data : PBuffer; Ok : Boolean; Begin ResourceHandle := BeginUpdateResource(pChar('d:\someexefile.exe'), False); IF (ResourceHandle <> 0) Then Begin FS := TFileStream.Create('d:\somebitmap.bmp', fmOpenRead); FS.Seek(0, soFromBeginning); DataLength := FS.Size; GetMem(Data, DataLength); FS.Read(Data^, DataLength); FS.Free; Ok := True; IF (not UpdateResource(ResourceHandle, RT_RCDATA, pChar('MyNewResource'), LANG_SYSTEM_DEFAULT{MakeLangID(LANG_NEUTRAL, SUBLANG_NEUTRAL)}, Data, DataLength)) Then Ok := False; IF (not EndUpdateResource(ResourceHandle, False)) Then Ok := False; IF (Ok) Then ShowMessage('Update of resources successful!') Else ShowMessage('Update of resources failed!'); FreeMem(Data); End; End. 
+4
source share
2 answers

Use LoadLibraryEx by passing LOAD_LIBRARY_AS_IMAGE_ RESOURCE to load the module, and then TResourceStream.SaveToFile to save the resource.

Of course, I assume that you do not want to extract the resource from the executable. If so, you can go straight to TResourceStream.SaveToFile .

+7
source

There are several tools you can use:

XN Resource Explorer

Resource hacker

Resource grabber

from code using DelphiDabbler .

or using the class TResourceStream . this question explains to you how to use it: How to extract a resource to a file at runtime?

+3
source

All Articles