title: Load a DLL From a Resource Directly From Memory in Delphi 7
body: <p>I put a dll file into a resources file (*.res)</p>
  
  <p><strong>ProjectTestLibrary.dll</strong>  </p>
  
  <pre><code>library ProjectTestLibrary;
  
  uses SysUtils, Classes, Dialogs;
  
  {$R *.res}
  
  procedure DllMessage; export;
  begin
    ShowMessage('Hello world from a Delphi DLL');
  end;
  
  exports DllMessage;
  
  begin
  end.
  </code></pre>
  
  <p><strong>MyTestDLL.rc</strong></p>
  
  <pre><code>TestDLL RCDATA ProjectTestLibrary.dll
  </code></pre>
  
  <p><strong>Produce MyTestDLL.res by this command line</strong>  </p>
  
  <pre><code>BRCC32 ProjectTestLibrary.rc
  </code></pre>
  
  <p><strong>In main form</strong></p>
  
  <pre><code>implementation
  {$R *.dfm}
  {$R MyTestDLL.RES}
  
  procedure DllMessage;  stdcall; external 'ProjectTestLibrary.dll';
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
      DllMessage;
  end;
  </code></pre>
  
  <p>Then error comes out<br>
  <strong>This application has failed to start because ProjectTestLibrary.dll was not found.</strong></p>
  
  <p>I understand that the problem because the dll file doesn't exist yet.<br>
  So I delete the 'DLLMessage;' code in onButton1Click.<br>
  Then onFormCreate, I added :</p>
  
  <pre><code>procedure TForm1.FormCreate(Sender: TObject);
  var ms : TMemoryStream;
      rs : TResourceStream;
  begin
    if 0 &lt;&gt; FindResource(hInstance, 'TestDLL', RT_RCDATA) then
    begin
      rs := TResourceStream.Create(hInstance, 'TestDLL', RT_RCDATA);
      ms := TMemoryStream.Create;
      ShowMessage('Found');
    end else
    begin
      ShowMessage('Not Found');
    end;
  end;
  </code></pre>
  
  <p>I run it again then pop-up message said 'Found'</p>
  
  <p>My question then :<br>
  1. How to save it in memory (not in PC hard drive), and finally<br>
  2. use its procedures/functions (procedure DLLMessage)</p>