title: Trying to get pixel color from screen coordinates, cant call my function
body: <p>I am trying to get the pixel color for set screen coordinates. I have a function I found and for some reason I can not call it. I placed it into a new class and I am trying to call it from my main form although it is not recognizing the function. It is a public class and a public function so I am not sure why. Thanks.</p>
  
  <pre><code>    #Region "#include"
      Imports System
      Imports System.Drawing
      Imports System.Runtime.InteropServices
      #End Region
      Public Class Test
  
      #Region "From Windows API"
      &lt;DllImport("user32.dll", SetLastError:=True)&gt; _
      Public Shared Function GetWindowDC(ByVal hwnd As IntPtr) As IntPtr
     'Do not try to name this method "GetDC" it will say that user32 doesnt have GetDC !!!
  End Function
  
  &lt;DllImport("user32.dll", SetLastError:=True)&gt; _
  Public Shared Function ReleaseDC(ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As Int32
  
  End Function
  
  &lt;DllImport("gdi32.dll", SetLastError:=True)&gt; _
  Public Shared Function GetPixel(ByVal hdc As IntPtr, ByVal nXPos As Integer, ByVal nYPos As Integer) As UInteger
  
  End Function
  #End Region
  REM --Test--
  #Region "Some Functions"
  Public Function GetPixelColor(ByVal x As Integer, ByVal y As Integer) As Color
      Dim hdc As IntPtr = GetWindowDC(IntPtr.Zero)
      Dim pixel As UInteger = GetPixel(hdc, x, y)
      Dim color As Color
      ReleaseDC(IntPtr.Zero, hdc)
      MsgBox(pixel)
      color = color.FromArgb(Int(pixel And &amp;HFF), _
      Int(pixel And &amp;HFF00) &gt;&gt; 8, _
      Int(pixel And &amp;HFF0000) &gt;&gt; 16)
      Return color
  End Function
  #End Region
  End Class
  </code></pre>