title: Delphi - Calling Win API
body: <p>What is the difference between calling an Win API in following codes</p>
  
  <p><strong>Code #1:</strong></p>
  
  <pre><code>uses
    Winapi.ActiveX;
  
  procedure Foo();
  var
    pv :Pointer;
  begin
    CoTaskMemFree(pv);
  end;
  </code></pre>
  
  <p><strong>Code #2:</strong></p>
  
  <pre><code>procedure CoTaskMemFree(
      pv: Pointer
      ); stdcall; external 'ole32.dll';
  
  procedure Foo();
  var
    pv :Pointer;
  begin
    CoTaskMemFree(pv);
  end;
  </code></pre>
  
  <p>I noticed the executable file size of <strong>Code 1</strong> (161,792 bytes) is bigger than executable file of <strong>code 2</strong> (23,552 bytes). i think that because of Code 1 will also compile the following units. </p>
  
  <pre><code>unit Winapi.ActiveX;
  
  uses Winapi.Messages, System.Types, Winapi.Windows;
  </code></pre>
  
  <ul>
  <li>Is there any other advantage of using the method used on <strong>#Code2</strong> ?</li>
  <li>Is there any risk of doing that ?</li>
  </ul>