.NET/Windows API for .NET
GetKeyboardLayoutList - System의 Keyboard Layout목록 반환
클리엘
2019. 8. 12. 11:42
728x90
GetKeyboardLayoutList는 Windows System에 설치된 모든 Keyboard의 Layout목록을 반환합니다.
Declare Function GetKeyboardLayoutList Lib "user32" Alias "GetKeyboardLayoutList" (ByVal nBuff As Integer, ByRef lpList As Integer) As Integer
▶VB.NET 선언
Dim kbl(255) As Integer
GetKeyboardLayoutList(254, kbl(0))
▶VB.NET 호출
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern int GetKeyboardLayoutList(int nBuff, ref int lpList);
▶C# 선언
int[] kbl = new int[255];
GetKeyboardLayoutList(254, ref kbl[0])
▶C# 호출
GetKeyboardLayoutList함수를 수행시키면 두번째 인수로 건네진 배열에 첫번째 인수에서 정한 크기만큼의 Layoutlist를 담게됩니다.
따라서 실제 Keyboard의 Layoutlist를 확인해 보려면 배열의 값을 확인해야 합니다.
Hex(Val((kbl(0))))
▶VB.NET 에서의 배열 확인
Convert.ToString(kbl[0], 16);
▶C#에서의 배열 확인
이 외에도 GetKeyboardLayoutList함수는 자체적으로 Layoutlist의 크기를 반환합니다.(첫번째 인수에 0을 주는 경우)
GetKeyboardLayoutList(0, kbl(0))
▶VB.NET List수 반환
GetKeyboardLayoutList(0, ref kbl[0]);
▶C# List수 반환
728x90