title: Why use DllImport Attribute as apposed to adding a reference?
body: <p>I've seen a couple of examples such as this:</p>
  
  <pre><code>[DllImport("user32.dll")]
  static extern bool TranslateMessage([In] ref Message lpMsg);
  
  [DllImport("user32.dll")]
  static extern IntPtr DispatchMessage([In] ref Message lpmsg);
  </code></pre>
  
  <p>But, what I don't understand is why someone would do that as apposed to just referencing the DLL like they do other libraries? The MSDN states: "The DllImport attribute is very useful when reusing existing unmanaged code in a managed application. For instance, your managed application might need to make calls to the unmanaged WIN32 API." But, is that saying it is not useful to reference an unmanaged dll or impossible otherwise?</p>