Solved

Get Windows Current Input Locale

Posted on 1998-10-15
5
512 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
Comment Utility
Edited text of question
0
 
LVL 2

Expert Comment

by:Poddy
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now