feiyangqingyun 发表于 2012-9-6 09:12:15

c#+TE6410+WINCE6.0实现中文输入法

WINCE上面自带没有中文输入法,需要自己加进去,办法很多,例如拷贝文件然后修改注册表然后重新编译烧写系统,而我这个办法呢,有点邪门!呵呵呵!直接C#代码来执行!
我这里准备的是万能拼音输入法的WINCE版本,默认是一个CAB安装文件Wnpy.ARMV4.CAB,首先第一步要找到这个输入法安装后增加了哪些文件,存放在哪个目录(一般默认Windows),用解压软件解压出来,有一些类似00WnpyCE.002的分卷压缩文件,找到_setup.xml,这个就是CAB安装文件的执行过程,用记事本打开,有一些这样的节点:
<characteristic type="FileOperation">
<characteristic type="%CE1%\wnpy" translation="install">
<characteristic type="MakeDir" />
<characteristic type="WnpyUnReg.exe" translation="install">
<characteristic type="Extract">
<parm name="Source" value="WNPYUN~1.001" />
</characteristic>
看到没,WnpyUnReg.exe,这个根据名称理解应该是反注册工具,依次可以找到包含如下文件WnpyUnReg.exe,WnpyReg.exe,WnpySetup.dll(这三个存放在用户安装时选定的目录下面的wnpy文件夹下)WnpyCE.dll(输入法核心文件,所有调用算法都在里面),Total_MB.txt(输入法的数据库文件,可以用记事本打开,里面就是词汇,拼音对应汉字),findIndex.idx(索引文件,快速检索词汇),Total_MB.idx(索引文件),(这四个文件放在Windows目录下),这样的话,我们首先安装一次,然后从对应文件夹拷贝这些文件出来,放到目录wnpy,输入法一般还会在注册表中注册,所以必须在注册表中增加对应的项,C#中注册表操作很方便,RegistryKey,需要引入命名空间,using Microsoft.Win32;方法如下:#region注册万能拼音输入法

      public static void LoadPinYin()
      {
            //创建注册表项
            RegistryKey BaseKey = Registry.ClassesRoot;
            RegistryKey CLSIDKey = BaseKey.OpenSubKey("CLSID", true);

            //创建万能拼音注册表项并赋值
            RegistryKey PinYinKey = CLSIDKey.CreateSubKey("{85EDDFAC-6799-4C3E-A627-E3CC1D28E0B1}");
            PinYinKey.SetValue("Default", "万能拼音", RegistryValueKind.String);

            //创建子项并赋值
            RegistryKey PinYinKey1 = PinYinKey.CreateSubKey("DefaultIcon");
            PinYinKey1.SetValue("Default", "\\NandFlash\\wnpy\\WnpyCE.dll,0", RegistryValueKind.String);

            RegistryKey PinYinKey2 = PinYinKey.CreateSubKey("InProcServer32");
            PinYinKey2.SetValue("Default", "\\NandFlash\\wnpy\\WnpyCE.dll", RegistryValueKind.String);

            RegistryKey PinYinKey3 = PinYinKey.CreateSubKey("IsSIPInputMethod");
            PinYinKey3.SetValue("Default", "1", RegistryValueKind.String);

            //拷贝文件到Windows目录
            CopyFile("Total_MB.idx");
            CopyFile("WnpyCE.dll");
            CopyFile("findIndex.idx");
            CopyFile("Total_MB.txt");
      }

      static void CopyFile(string FileName)
      {
            try
            {
                if (!File.Exists("\\Windows\\" + FileName))
                {
                  File.Copy("\\NandFlash\\wnpy\\" + FileName, "\\Windows\\" + FileName, true);
                }
            }
            catch { }
      }

      #endregion
这样的话只要发布软件的时候将wnpy目录拷贝到NandFlash目录下,然后程序里面在main函数中执行LoadPinYin()即可!简单吧!呵呵!static void Main()
      {
            myHelper.LoadPinYin();
            Application.Run(new frmMain());            
      }

feiyangqingyun 发表于 2012-9-6 09:15:52

WINCE 在BSP中注册输入法
1.使用ActiveSync拷贝如下文件到平台的FILES目录下touchp.dll,tlcesrv.dll,recoggbk.dll,ppsipgb.dll,ppgbpy.dll,ppengbk.bin,cetlstub.dll,cemgrc.exe
2.在platform.bib文件中添加如下touchp.dll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(_FLATRELEASEDIR)\touchp.dll&nbsp;&nbsp;&nbsp;NK&nbsp;&nbsp;Utlcesrv.dll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(_FLATRELEASEDIR)\tlcesrv.dll&nbsp;&nbsp;NK&nbsp;&nbsp;Urecoggbk.dll&nbsp;&nbsp;&nbsp;&nbsp;$(_FLATRELEASEDIR)\recoggbk.dll&nbsp;&nbsp;NK&nbsp;&nbsp;Uppsipgb.dll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(_FLATRELEASEDIR)\ppsipgb.dll&nbsp;&nbsp;NK&nbsp;&nbsp;Uppgbpy.dll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(_FLATRELEASEDIR)\ppgbpy.dll&nbsp;&nbsp;&nbsp;NK&nbsp;&nbsp;Uppengbk.bin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(_FLATRELEASEDIR)\ppengbk.bin&nbsp;&nbsp;NK&nbsp;&nbsp;Ucetlstub.dll&nbsp;&nbsp;&nbsp;&nbsp;$(_FLATRELEASEDIR)\cetlstub.dll&nbsp;&nbsp;NK&nbsp;&nbsp;Ucemgrc.exe&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(_FLATRELEASEDIR)\cemgrc.exe&nbsp;&nbsp;&nbsp;NK&nbsp;&nbsp;U
&nbsp;
3.在platform.reg中添加如下内容@="蒙恬输入法""Setting_RecogType"=dword:0000017f"Setting_UseType"=dword:000005e6"Setting_WhichShapeType"=dword:00000002"Setting_ShapeTypeBig5"=dword:00000007"Setting_ShapeTypeGB"=dword:00000009"Setting_ShapeTypeMix"=dword:0000001f"Setting_PenColor"=dword:00000000"Setting_PenWidth"=dword:00000002"Setting_WritingSpeed"=dword:00000003"Setting_AI"=dword:00000001
@="\\Windows\\ppsipgb.dll,0"
@="\\Windows\\ppsipgb.dll"
@="1"
4.重新编译系统,生成内核,烧写完成,启动系统就可以选择蒙恬输入法了
5.系统默认的还是原来的输入法,可以通过修改注册表来改变

把蒙恬输入法的{35716243-ae04-11d0-a4f8-00aa00a749b9}替换下面的位置
&nbsp;
DefaultIm={DF2BF912-1A9A-11D2-8F>**00C04FAC52F9}
保存注册表后就可以了。
页: [1]
查看完整版本: c#+TE6410+WINCE6.0实现中文输入法