# ReleaseDC Function

`Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As Long, ByVal hdc As Long) As Long`

ReleaseDC frees up the resources used when you use GetDC to get an object's device context. This should be done after your program finishes using the device context. The function returns 0 if an error occured or a non-zero value if successful.

hWnd
  The handle of the object to free the resources of.
hdc
  The device context of the object to free the resources of.

Example:

    ' Example for ReleaseDC
    deskhwnd = GetDesktopWindow()  ' API gets handle to desktop
    deskhdc = GetDC(deskhwnd)  ' gets desktop's device context
    ' put code that uses deskhdc here
    x = RelaseDC(deskhwnd, deskhdc)  ' free up resources

Related Call: GetDC
Category: Devices
Back to the index.