1. 切换输入法
#include
bool load_ime( char* ime_name )
{
UINT cnt;
HKL FAR *lpKL;
char szImeName[13];
HKL hKLReturn = 0;
cnt = GetKeyboardLayoutList(0, NULL);
if (!cnt) {
/* error. */
}
lpKL = (HKL FAR *)LocalAlloc(LPTR, sizeof(HKL) * cnt);
if (!lpKL) {
/* not enough memory. */
}
cnt = GetKeyboardLayoutList(cnt, lpKL);
if (!cnt) {
/* error. */
}
while (0 < cnt) {
cnt--;
if (ImmGetIMEFileName(*(lpKL + cnt),
szImeName, sizeof(szImeName))
&& !lstrcmpi(ime_name, szImeName))
{
hKLReturn = *(lpKL + cnt);
break;
}
// ImmGetIMEFileName(*(lpKL + cnt),
// szImeName, sizeof(szImeName));
// OutputDebugString( szImeName );
}
LocalFree(lpKL);
if( hKLReturn != 0 )
{
ActivateKeyboardLayout( hKLReturn, 0 );
return true;
}
else
return false;
}
void CTestcursorDlg::OnButton1()
{
load_ime( "unispim.ime" ); // 紫光
// load_ime( "PINTLGNT.IME" ); // 微软拼音
}
//获取当前输入法名字
function getimefilename: string;
var
szimefilename: array[0..max_path] of char;
begin
if immgetimefilename(getkeyboardlayout(0), szimefilename, max_path) <> 0 then
result := ansiuppercase(strpas(szimefilename))
else
result := ;
end;
阅读(1499) | 评论(0) | 转发(0) |