How does the HKL struct look like?
-
Hello, Im trying to implement the GetKeyboardLayoutList method from user32.dll in my .Net1.1 WinApp. Like this: [DllImport("user32")] private static extern UInt32 GetKeyboardLayoutList(int nBuff,ref HKL[] lpList); Here is the MSDN info: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/activatekeyboardlayout.asp[^] I also Googled for it, but couldn't find out what the HKL struct looks like. Thanks for your help and suggestions. All the best, Martin
-
Hello, Im trying to implement the GetKeyboardLayoutList method from user32.dll in my .Net1.1 WinApp. Like this: [DllImport("user32")] private static extern UInt32 GetKeyboardLayoutList(int nBuff,ref HKL[] lpList); Here is the MSDN info: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/activatekeyboardlayout.asp[^] I also Googled for it, but couldn't find out what the HKL struct looks like. Thanks for your help and suggestions. All the best, Martin
Martin I believe that the reference should look like this:
[DllImport("user32.dll")] public static extern int GetKeyboardLayoutList(int nBuff, ref int lpList);
Then, in your code, you would work with it like this:
int[] layouts = new int[1]; int length = GetKeyboardLayoutList(0, ref layouts[0]); layouts = new int[length]; GetKeyboardLayoutList(layouts.Length, ref layouts[0]);
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before. -
Martin I believe that the reference should look like this:
[DllImport("user32.dll")] public static extern int GetKeyboardLayoutList(int nBuff, ref int lpList);
Then, in your code, you would work with it like this:
int[] layouts = new int[1]; int length = GetKeyboardLayoutList(0, ref layouts[0]); layouts = new int[length]; GetKeyboardLayoutList(layouts.Length, ref layouts[0]);
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.Hello Pete, It works!!!! :cool: Thanks a lot. Actually I made the mistake to define it as an array. like this:
[DllImport("user32.dll")]
public static extern int GetKeyboardLayoutList(int nBuff, ref int[] lpList);int[] layouts = new int[1];
int length = GetKeyboardLayoutList(0, ref layouts);
layouts = new int[length];
GetKeyboardLayoutList(layouts.Length, ref layouts);This was strange because the first call of GetKeyboardLayoutList returned the write value (Lenght of 3). But the second call, brought back a lenght of 1 with a value 0. :confused: But with your help everything is fine now. (And it was not the first time of corse!) So thank you very much again. All the best, Martin