.NET/Windows API for .NET

ReleaseDC - Device Context 초기화

클리엘 2019. 8. 6. 16:16
728x90

ReleaseDC함수는 다른 함수에 의해 열린 Device Context를 닫고 초기화 시키는 함수입니다.

Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Integer, ByVal hdc As Integer) As Integer

▶VB.NET 선언

[DllImport("user32")]
public static extern int ReleaseDC(int hwnd, int hdc);

▶C# 선언


ReleaseDC 함수의 첫번째 인수는 Device Context와 관련된 Handle을 기술하며 두번째 인수에 초기화 하고자 하는 Device Context를 작성하도록 합니다.

예를 들어 현재 Window Desktop의 Device Context를 초기화 하고자 한다면 ReleaseDC함수는 다음과 같이 호출될 수 있습니다.

ReleaseDC(GetDesktopWindow(), GetDC(GetDesktopWindow))

▶VB.NET 호출

ReleaseDC(GetDesktopWindow(), GetDC(GetDesktopWindow()));

▶C# 호출


위에서 쓰인 GetDesktopWindow()함수는 현재 Desktop의 handle을 GetDC()함수는 지정된 handle로 부터 Device Context를 구하는 함수입니다. 자세한 내용은 아래 글을 참고 하시기 바랍니다.

[Windows API for .NET] - GetDC - Window및 Control의 Device Context 구하기
[Windows API for .NET] - GetWindowDC - 현재 Windows화면의 Device Context 구하기

이 함수는 실행에 실패하는 경우 0을 반환합니다.

728x90