title: How do I read a uint from a pointer with Marshalling?
body: <p>I have a native method which needs a pointer to write out a dword (uint).</p>
  
  <p>Now I need to get the actual uint value from the (Int)pointer, but the Marshal class only has handy methods for reading (signed) integers.</p>
  
  <p>How do I get the uint value from the pointer?</p>
  
  <p>I've searched the questions (and Google), but couldn't really find what I needed.</p>
  
  <p>Sample (not working) code:</p>
  
  <pre><code>IntPtr pdwSetting = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(uint)));
  
          try
          {
              // I'm trying to read the screen contrast here
              NativeMethods.JidaVgaGetContrast(_handleJida, pdwSetting);
              // this is not what I want, but close
              var contrast = Marshal.ReadInt32(pdwSetting);
          }
          finally
          {
              Marshal.FreeHGlobal(pdwSetting);
          }
  </code></pre>
  
  <p>The return value from the native function is a dword between 0 and 255 with 255 being full contrast.</p>