2022年5月31日 星期二

delphi image TResourceStream standard Microsoft SDK resource compiler

  standard Microsoft SDK resource compiler

 https://github.com/graphics32/GR32PNG

 RC.EXE, the Microsoft SDK Resource Compiler

https://forum.lazarus.freepascal.org/index.php?topic=12312.0
https://www.wireshark.org/docs/wsdg_html_chunked/ChToolsMSChain.html

https://support.microsoft.com/en-us/topic/an-updated-resource-compiler-for-the-windows-sdk-for-windows-server-2008-and-for-the-net-framework-3-5-is-now-available-a716ac6a-19a7-5b45-b5df-55980cd4cdb4
https://archicadapi.graphisoft.com/documentation/graphisoft-resource-compiler-4
https://docs.microsoft.com/zh-tw/windows/win32/menurc/resource-compiler
https://en.wikibooks.org/wiki/Windows_Programming/Resource_Scripts

Var

   jpg: TJPEGImage;
 resStream: TResourceStream;

begin
  jpg := TJPEGImage.Create;
  resStream := TResourceStream.Create(HInstance, 'testJpg', 'jpgtype');
  jpg.LoadFromStream(resStream);
  Image1.Picture.Assign(jpg);
  jpg.Free;
  resStream.Free;
end;

//RC: testBmp bitmap res\test.bmp
Image1.Picture.Bitmap.LoadFromResourceName(HInstance, 'res\test.bmp');
//RC: testBmp bmptype res\test.bmp
var
  resStream: TResourceStream;
begin
  resStream := TResourceStream.Create(HInstance, 'testBmp', 'bmptype');
  Image1.Picture.Bitmap.LoadFromStream(resStream);
  resStream.Free;
end;

http://melander.dk/reseditor/

https://wiki.freepascal.org/Lazarus_Resources

https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/menurc/resource-compiler.md
 Microsoft platform SDK Resource Compiler
https://docwiki.embarcadero.com/RADStudio/Sydney/en/RC.EXE,_the_Microsoft_SDK_Resource_Compiler

 https://delphi.cjcsoft.net/viewthread.php?tid=43646
Title: Extracting Resource Data from an Exe
Question: Article 832 mentions how one can put Files into an Exe. This shows you how you can get it out
Answer:
I've written a simple function that does this for you, just cut and paste (some detail is below)

procedure ExtractToFile(Instance:THandle; ResID:Integer; ResType, FileName:String);
var
  ResStream: TResourceStream;
  FileStream: TFileStream;
begin
  try
    ResStream := TResourceStream.CreateFromID(Instance, ResID, pChar(ResType));
    try
      //if FileExists(FileName) then
        //DeleteFile(pChar(FileName));
      FileStream := TFileStream.Create(FileName, fmCreate);
      try
        FileStream.CopyFrom(ResStream, 0);
      finally
        FileStream.Free;
      end;
    finally
      ResStream.Free;
    end;
  except
    on E:Exception do
    begin
      DeleteFile(FileName);
      raise;
    end;
  end;
end;

https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TResourceStream

https://github.com/osmanatam/delphi-foundations/tree/ea2c878f01107146674bd92ea518908d8f3e185d/XE2%20book/08.%20Streams/TResourceStream

沒有留言: