WinXP/WinXP Embedded API to change IME


I am looking for an API on WinXP to switch between installed IME's. The scenario is, to be able to plug in a langauge keyboard (say Spanish) and change the IME by clicking on a 'language name button' on the UI (say button named Spanish)

Who is Participating?
manavsharmaConnect With a Mentor Author Commented:
Thanks for the reply mannujam. I was trying to change the locale/ IME (which falls under the locale).
I found that there is an api named, 'SystemParametersInfo' which allows us to make settings on system level. In my case, I had to go to Control Panel > Regional Settings > and then switch between installed locales under Language tab. This could finally be achieved programatically as shown in the code:
// testing_SystemParametersInfo.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "windows.h"
int _tmain(int argc, _TCHAR* argv[])
	HKL hLangId = 0;
	bool isFine;
	DWORD errorCode;
	errorCode = GetLastError();
	isFine = SystemParametersInfo(SPI_GETDEFAULTINPUTLANG, 0, &hLangId, 0);
	errorCode = GetLastError();
	HKL spanishLanguage = (HKL) (0x040a0c0a);
	isFine = SystemParametersInfo(SPI_SETDEFAULTINPUTLANG, 0, &spanishLanguage, 0);
	errorCode = GetLastError();
	return 0;

Open in new window

You can use keybd_event for switching in between installed ime
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), 0, 0);
keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);      

OK,  that'a fine
I thought  for switching between installed IME's  (langauge keyboard / LAnguage bar) shown nin staus bar,
SPI_(GET/SET)DEFAULTINPUTLANG  works fine for sublocale or locale

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.