views:

587

answers:

1

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 UI button (say button named Spanish)

e.g. I plug in a Spanish keyboard and click on the UI button named Spanish. This should internally change the IME to Spanish, which is already installed

Thanks

A: 

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:

#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;

}