RelaseDC is delcare like this.

VB Code:
  1. Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

As you can see you need a handle to the window that the device context is to be released. I guess since you use 0 as your handle to get the device context you can use that as your first parameter. I am not positive because anytime I got a device context I always had a window handle, but in your case you don't.

VB Code:
  1. 'So you can write you code like this.
  2.  
  3. ReleaseDC 0, hdc