Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How does the HKL struct look like?

How does the HKL struct look like?

Scheduled Pinned Locked Moved C#
csharpcomhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Martin 0
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • M Martin 0

      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

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • P Pete OHanlon

        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.

        M Offline
        M Offline
        Martin 0
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups