fff.cpp
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:3k
- // fff.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "windows.h"
- #include "setup.h"
- #include "imm.h"
- #include "RegeditOP.h"
- int setupIME();
- RegeditOP regop;
- int main(int argc, char* argv[])
- {
- // char ss[1000];
- setup mysetup;
- setupIME();
- // getchar();
- return 0;
- }
- //保存输入法的次序
- int SaveOrderIME(HKL instHKL)
- {
- char ss[1000],retss[100],temss[100],tempath[1000];
- int i,t=1,num;
- HKL hKB[100];
- ActivateKeyboardLayout ((HKL)804, 0);
- SetKeyboardState((unsigned char *)&"00000804");
- LoadKeyboardLayout("00000804", KLF_REORDER);
- num = GetKeyboardLayoutList(25, hKB) ;//取得所有输入法
- for(i=0;i<num;i++)
- {
- sprintf(retss,"%x",hKB[i]);
- if(ImmIsIME(hKB[i])==0||strlen(retss)<8)
- {
- sprintf(retss,"%x",(unsigned short int)hKB[i]);
- sprintf(temss,"00000000");
- sprintf(&temss[8-strlen(retss)],retss);
- sprintf(ss,"%d",t);
- regop.RegSaveString("Keyboard Layout\Preload",ss, temss);
- sprintf(tempath,"Keyboard Layout\Preload\%d",t);
- regop.RegSaveString(tempath,"", temss);
- if(t==1)
- {
- SetKeyboardState((unsigned char *)&temss);
- LoadKeyboardLayout(temss, KLF_REORDER);
- //MessageBox(0,temss,temss,0);
- }
- t++;
- }
- }
- //保存当 前安装的输入法
- sprintf(ss,"%d",t);
- sprintf(retss,"%x",instHKL);
- regop.RegSaveString("Keyboard Layout\Preload",ss, retss);
- sprintf(tempath,"Keyboard Layout\Preload\%d",t);
- regop.RegSaveString(tempath,"", retss);
- t++;
-
- for(i=0;i<num;i++)
- {
- sprintf(retss,"%x",hKB[i]);
- if(ImmIsIME(hKB[i])==1 && hKB[i]!=instHKL&&strlen(retss)==8 )//跳过当前输入法
- {
- sprintf(ss,"%d",t);
- regop.RegSaveString("Keyboard Layout\Preload",ss, retss);
- sprintf(tempath,"Keyboard Layout\Preload\%d",t);
- regop.RegSaveString(tempath,"", retss);
- t++;
- }
- }
- return 0;
- }
- int setupIME()
- {
- char ss[1000];
- char Path[1000];
- char filecopy[1000];
- setup mysetup;
- int ret;
- HKL dd;
- HKL hCurKBDLayout;
- sprintf(Path,"%s", "C:\jsime");
- mysetup.copypathfile(Path);//把当前目录下的所有文件复制到工作目录下。
- sprintf(filecopy,"%s%s", mysetup.AppPath,"\SysPath.txt");
- mysetup.FileCopyBAT(mysetup.AppPath,mysetup.SysPath,filecopy);
-
- //////////////////////////////////////////////////////////////////////
- //激活输入法
- sprintf(ss,"%s%s", mysetup.SysPath,"\whjsmb.ime");
-
- dd = ImmInstallIME(ss,"极速五笔");
- if(dd != 0)
- {
- sprintf(ss,"%x", dd);
- sprintf(Path,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\%s",ss);
- regop.RegSaveString(HKEY_LOCAL_MACHINE,Path,"Layout Display Name", "中文 极速五笔JSWH");
- ret=MessageBox(0,"是否调整输入法顺序","whjsmb安装成功",1);
- if(ret==1)
- {
- //修改输入法顺序
- hCurKBDLayout = GetKeyboardLayout(0); //取得目前的输入法
- ActivateKeyboardLayout (dd, 0);
- SetKeyboardState((unsigned char *)&ss);
- LoadKeyboardLayout(ss, KLF_REORDER);
- SaveOrderIME(dd);
- ActivateKeyboardLayout (hCurKBDLayout, 0);
- }
- }
- else
- MessageBox(0,"安装失败!请检查文件","whjsmb",0);
- return 0;
- }