Mega Code Archive

 
Categories / Delphi / Examples
 

Recover a dfm from your exe

How to get a DFM back from a delphi compiled EXE. function ExtractDFM(ApplicationName, FormClassName: string): string; var AppHandle: THandle; ResStream: TResourceStream; ResultStream: TStringStream; begin Result := ''; AppHandle := LoadLibraryEx(PChar(ApplicationName), 0, LOAD_LIBRARY_AS_DATAFILE); if AppHandle = 0 then raise Exception.Create('Could not load application'); ResStream := nil; ResultStream := nil; try ResStream := TResourceStream.Create(AppHandle, FormClassName, RT_RCDATA); ResultStream := TStringStream.Create(''); ObjectBinaryToText(ResStream, ResultStream); Result := ResultStream.DataString; finally ResultStream.Free; ResStream.Free; FreeLibrary(AppHandle); end; end;