title: Using Windows API functions in .NET
body: <p>I asked a question some time ago here: <a href="https://stackoverflow.com/questions/12680981/com-vs-non-com-dll">COM vs non-COM DLL</a> about calling a classic C++ program from .NET.  </p>
  
  <p>The answer (from Hans Passant) was to write a wrapper class in Visual C++, which worked out well in my project (I did get some help with this from another developer who is more commerically experienced with C++).  </p>
  
  <p>My question is: is there wrapper classes created for some of the functions in the WINAPI.  For example, the code below works without a wrapper class:</p>
  
  <pre><code>Imports System.Runtime.InteropServices
  Imports System.Text
  
  Public Class Form1
  
      &lt;DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Ansi)&gt; _
      Public Shared Function MessageBox(ByVal hwnd As IntPtr, &lt;MarshalAs(UnmanagedType.LPStr)&gt; ByVal lpString As String, &lt;MarshalAs(UnmanagedType.LPStr)&gt; ByVal lpString2 As String, ByVal cch As Integer) As Integer
      End Function
  
      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          MessageBox(0, "HelloWorld", "HelloWorld", 0)
      End Sub
  End Class
  </code></pre>