.NET/Windows API for .NET

    GetKeyboardState - Keyboard Key및 Mouse Button상태확인

    GetKeyboardState() 함수는 Keyboard의 Key입력이나 Mouse Button의 누름상태를 반환합니다. Private Declare Function GetKeyboardState Lib "user32" Alias "GetKeyboardState" (ByVal pbKeyState() As Byte) As Integer ▶VB.NET 선언 Private VirKey(256) As Byte GetKeyboardState(VirKey) VirKey(X) ▶VB.NET 호출 [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern int GetKeyboardState(byte[] pbKeyState); ▶C# 선..

    Windows API

    1. API API는 Application Programming Interface의 약자로 Software개발시에 특정기능을 구현하려고 처음부터 새로 Program을 작성하는 것이 아니라 다른 Library에 의해 이미 구현되어 있는 기능을 개발하고자 하는 Software에 손쉽게 추가할 수 있는 것을 말합니다. 예를 들어 영어사전이나 국어사전 Program을 구현하고자 하는 경우 Naver나 Google등에서 제공하는 API를 끌어다 쓰면 단 몇줄 만으로도 훌륭한 사전 Program을 개발할 수 있게 되는 것입니다. 여기서 Windows API는 System에 대한 각종 정보를 알아내거나 운영체제(OS : 여기서는 Windows)의 특정 기능을 Program안에서 구현하고자 할때마다 편리하고도 간단하게..

    GetFocus - 현재 Focus에 있는 Form또는 Control의 handle값 반환

    GetFocus는 현재 Focus상태에 있는 Control이나 Form의 handle값을 반환하는 함수 입니다. Declare Function GetFocus Lib "user32" Alias "GetFocus" () As Integer ▶VB.NET 선언 GetFocus() ▶VB.NET 호출 [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern int GetFocus(); ▶C# 선언 GetFocus() ▶C# 호출 참고로 이 함수는 Form이나 Control의 handle method의 반환값과 같습니다.

    GetActiveWindow - 현재 프로그램의 윈도우 핸들값

    Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Integer ▶VB.NET 선언 GetActiveWindow() ▶VB.NET 호출 [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern int GetActiveWindow(); ▶C# 선언 GetActiveWindow() ▶C# 호출 GetActiveWIndow는 현재 함수를 호출하고 있는 Program(Thread)과 관련된 Windows의 handle값을 반환합니다. 만일 관련된 Windows화면이 존재하지 않는 경우에는 null을 반환합니다.

    ActivateKeyboardLayout - Keyboard 언어별 선택함수

    ActivateKeyboardLayout - Keyboard 언어별 선택함수

    Windows OS에 다음과 같이 Keyboard가 언어별로 설정되어 있을때 ActivateKeyboardLayout 함수는 Keyboard설정중 하나를 선택할 수 있도록 합니다. Declare Function ActivateKeyboardLayout Lib "user32" Alias "ActivateKeyboardLayout" (ByVal HKL As Integer, ByVal flag As Integer) As Integer ▶VB.NET 선언 Private Const HKL_NEXT As Integer = 0 Private Const HKL_PREV As Integer = 1 ActivateKeyboardLayout(HKL_NEXT, 8) ▶VB.NET 호출 [System.Runtime.Intero..

    CopyMemory - Memory 복사

    Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Char, ByRef Source As Char, ByVal Length As Integer) ▶VB.NET 선언 Dim a As Char = "X" Dim B As Char CopyMemory(B, a, 1) B ▶VB.NET 호출 [System.Runtime.InteropServices.DllImport("kernel32.dll")] public static extern void CopyMemory(ref char Destination, ref char Source, int Length); ▶C# 선언 char a = 'X'; char B = ' '; Co..

    SystemParameterInfo - Windows System 환경설정

    SystemParameterInfo API함수는 제어판이나 기타 다른방식등을 통해 설정가능한 Windows OS의 여러가지 환경을 제어할 수 있는 함수입니다. 1. 배경화면 변경 Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer ▶VB.NET 선언 Declare Auto Function SystemParametersInfo Lib "user32.dll" (ByVal uAction As Integer,..

    SetComputerName - Computer Network 이름 바꾸기

    Declare Function SetComputerName Lib "Kernel32" Alias "SetComputerNameA" (ByVal IpComputerName As String) As Integer ▶C# 선언 If SetComputerName("OpenLab") = 0 Then MessageBox.Show("Computer 이름 바꾸기 실패") Else MessageBox.Show("Computer 이름 바꾸기 성공") End If ▶C# 호출 [System.Runtime.InteropServices.DllImport("Kernel32.dll")] private static extern int SetComputerName(string IpComputerName); ▶VB.NET 선언 if (..