선언:

IsWindow (C#)
[DllImport("user32")]
static extern bool IsWindow(IntPtr hWnd);

IsWindow (VB.NET)
<DllImport("user32")> _
Shared Function IsWindow(ByVal hWnd As IntPtr) As Boolean
End Function



사용 예제:

IsWindow Example (C#)
using System;
using System.Runtime.InteropServices;

namespace ApiReference {
    class ApiExample {
        [DllImport("user32")]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32")]
        public static extern bool IsWindow(IntPtr hWnd);
        
        public static void Main(string[] args) {
            IntPtr hNotepad = FindWindow("Notepad", null);
            
            if ( hNotepad != IntPtr.Zero ) {
                if ( IsWindow(hNotepad) )
                    Console.WriteLine("유효한 윈도우 핸들입니다.");
                else
                    Console.WriteLine("유효하지 않은 윈도우 핸들입니다.");
            } else
                Console.WriteLine("메모장이 없습니다.");
            
            Console.ReadKey(true);
        }
    }
}
예제 코드 (.NET Fiddle)


IsWindow Example (VB.NET)
Imports System
Imports System.Runtime.InteropServices

    Class ApiExample
    
    <DllImport("user32")>
    Public Shared Function FindWindow(lpClassName As String, lpWindowName As String) As IntPtr
    End Function
    
    <DllImport("user32")>
    Public Shared Function IsWindow(hWnd As IntPtr) As Boolean
    End Function
    
    Public Shared Sub Main(args As String())
        Dim hNotepad As IntPtr = FindWindow("Notepad", Nothing)
        If hNotepad <> IntPtr.Zero
            If IsWindow(hNotepad)
                Console.WriteLine("유효한 윈도우 핸들입니다.")
            Else
                Console.WriteLine("유효하지 않은 윈도우 핸들입니다.")
            End If
        Else
            Console.WriteLine("메모장이 없습니다.")
        End If
        
        Console.ReadKey(True)
    End Sub
End Class
예제 코드 (.NET Fiddle)




예제 실행 결과:




매개변수 설명(기울임꼴로 표시된 매개변수는 생략 가능합니다):

hWnd - 확인할 윈도우의 핸들을 입력합니다.




API 설명:

주어진 핸들이 유효한 윈도우 핸들인지를 확인합니다.




참고:

IsWindow (MSDN)




요구 사항:

Windows 2000 프로페셔널 이상

Windows 2000 Server 이상




비고:

-




.NET Fiddle 의 .NET 보안 수준으로 인해 P/Invoke 를 직접 테스트하실 수 없습니다. .NET Fiddle 사이트는 코드 참고용으로만 이용해 주시기 바랍니다.
Powered by SlaneR & TeamDEV Korea


'API Reference' 카테고리의 다른 글

61. LoadLibraryEx  (0) 2015.10.03
60. RegisterWindowMessage  (0) 2015.10.03
58. SystemFunction041 (RtlDecryptMemory)  (0) 2015.09.27
57. SystemFunction040 (RtlEncryptMemory)  (0) 2015.09.26
56. CreateFile  (2) 2015.09.14

+ Recent posts