Solved

Get Windows Current Input Locale

Posted on 1998-10-15
5
521 Views
Last Modified: 2006-11-17
My user is running US English version of Windows NT with several Input Locales (Keyboard languages) installed. How can I programmatically find out which Input Locale is current, and how my application can detect when the Input Locale changes. Using GetSystemDefaultLCID or GetSystemDefaultLangID APIs (no matter) I can only obtain the default Windows language, not the one currently in use.
0
Comment
Question by:tbbrhun
  • 3
  • 2
5 Comments
 

Author Comment

by:tbbrhun
ID: 1440141
Edited text of question
0
 
LVL 2

Expert Comment

by:Poddy
ID: 1440142
The function you seek is GetKeyboardLayout

Pass zero as its parameter (indicating current thread)

the low word is the input language locale
the hi word is the physical layout
(these may be the same)
0
 

Author Comment

by:tbbrhun
ID: 1440143
Poddy, can you be a little more specific about the low and high words and how to work with them after the API executed. I'm not really getting the your answer, but it looks like you know what you are talking about. I'd like to hear more from you.
0
 
LVL 2

Accepted Solution

by:
Poddy earned 200 total points
ID: 1440144
dim lngRet as long
dim lngHi as long
dim lngLo as long

lngRet=GetKeyboardLayout(0)
lngHi=lngRet \ 65536
lngLo=lngRet mod 65536

specifically, the return value is a 4 byte value:
The high word is the first two bytes and the low word is the second pair.

So to extract the high word, divide the result by 65536 (2 ^16)
and to extract the low word, take the remainder (MODulo) of this division.  

So if you set up a keyboard with US Language in British layout, the return values will be 2057 in the high word and 1033 in the low word.

2057 (&H0809)is the locale ID for British English
1033 (&H0409)is the locale ID for US English


any questions...?
0
 

Author Comment

by:tbbrhun
ID: 1440145
Hey Poddy! By the time I got it I figured it out myself, but you get your points anyway, THANKS. That solves half of my problem. Now, is there any way to detect in my application when the user changes the locale. I would spend another 100 point for that. Please respond to BDH4628@ix.netcom.com. If you have the solution, I will re-submit the question through Exchange for you to get points. THANKS again!!!!!!!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question