title: Pointer typecasting in Delphi
body: <p>How can I correctly typecast to a structure in Delphi? This does not work exactly like in <code>C++</code> where one would just pass a <code>&amp;Data</code> according to the MSDN documentation.</p>
  
  <pre><code>program Project1;
  
  uses
    System.SysUtils,
    Winapi.Windows,
    Winapi.Winsock2;
  
  function WSAStartup(wVersionRequired: WORD; out lpWSAData: LPWSADATA): Integer; WINAPI; external 'ws2_32.dll';
  
  var
    Data: WSADATA;
  begin
    WSAStartup(WINSOCK_VERSION, LPWSADATA(@Data)); // E2197 Constant object cannot be passed as var parameter
    ReadLn;
  end.
  </code></pre>