runres.dpr

来自「在内存中动态运行可执行程序的演示」· DPR 代码 · 共 41 行

DPR
41
字号
{=======================================================}
{                                                       }
{         DelphiUpx- 内存运行EXE文件演示程序           }
{                                                       }
{    版权所有 (c) 2004 陈经韬.lovejingtao@21cn.com      }
{                                                       }
{                            http://www.138soft.com     }
{=======================================================}

program RunRes;

uses
  Windows,
  {如果该资源里面的EXE文件引用了VCL窗口,则必须引用Forms}
  MemoryRun;

{$R *.res}
{$R Setup.res} //包含资源文件.
var
  ResourceLocation: HRSRC;
  ResourceSize: LongWord;
  ResourceHandle: THandle;
  ResourcePointer: Pointer;
begin
  ResourceLocation := FindResource(HInstance, pchar('setup'), 'exefile');
  if ResourceLocation <> 0 then
  begin
    ResourceSize := SizeofResource(HInstance, ResourceLocation);
    if ResourceSize <> 0 then
    begin
      ResourceHandle := LoadResource(HInstance, ResourceLocation);
      if ResourceHandle <> 0 then
      begin
        ResourcePointer := LockResource(ResourceHandle);
        if ResourcePointer <> nil then CjtMemoryRun(ResourcePointer);
      end;
    end;
  end;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?