VISTA 与输入法程式介面
VISTA 与输入法程式介面
|
public void GetLanguages()
{
(在InputLanguage.InstalledInputLanguages中的InputLanguage lang)
{
textBox1.Text + = lang.Culture.EnglishName +'\ n';
}
}
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
// Microsoft文本服务框架声明
//从C ++头文件
//
//////////////////////////////////////////////////////////////////////////////////////////////
使用系统;
使用System.ComponentModel;
使用System.Collections.Generic;
使用System.Text;
使用System.Runtime.InteropServices;
使用System.Security;
命名空间TSF
{
[ StructLayout(LayoutKind .Sequential)]
内部 结构 TF_LANGUAGEEPROFILE
{
内部 Guid clsid;
内部 短 LANGID;
内部 Guid catid;
[ MarshalAs(UnmanagedType .Bool)]
内部 布尔功能;
内部 Guid guidProfile;
}
[ ComImport,SecurityCritical,SuppressUnmanagedCodeSecurity,
Guid (“1F02B6C5-7842-4EE6-8A0B-9A24183A95CA”),
InterfaceType(ComInterfaceType .InterfaceIsIUnknown)]
内部 接口 ITfInputProcessorProfiles
{
[ SecurityCritical ]
void Register(); //非执行!可能是错误的声明。
[ SecurityCritical ]
void Unregister(); //非执行!可能是错误的声明。
[ SecurityCritical ]
void AddLanguageProfile(); //非执行!可能是错误的声明。
[ SecurityCritical ]
void RemoveLanguageProfile(); //非执行!可能是错误的声明。
[ SecurityCritical ]
void EnumInputProcessorInfo(); //非执行!可能是错误的声明。
[ SecurityCritical ]
int GetDefaultLanguageProfile(short langid,ref Guid catid,out Guid clsid,out Guid profile);
[ SecurityCritical ]
void SetDefaultLanguageProfile(); //非执行!可能是错误的声明。
[ SecurityCritical ]
int ActivateLanguageProfile(ref Guid clsid,short langid,ref Guid guidProfile);
[ PreserveSig,SecurityCritical ]
int GetActiveLanguageProfile(ref Guid clsid,out short langid,out Guid profile);
[ SecurityCritical ]
int GetLanguageProfileDescription(ref Guid clsid,short langid,ref Guid profile,out IntPtrdesc);
[ SecurityCritical ]
void GetCurrentLanguage(out short langid); //非执行!可能是错误的声明。
[ PreserveSig,SecurityCritical ]
int ChangeCurrentLanguage(short langid); //非执行!可能是错误的声明。
[ PreserveSig,SecurityCritical ]
int GetLanguageList (out IntPtr langids,out int count);
[ SecurityCritical ]
int EnumLanguageProfiles(short langid,out IEnumTfLanguageProfiles enumIPP);
[ SecurityCritical ]
int EnableLanguageProfile();
[ SecurityCritical ]
int IsEnabledLanguageProfile(ref guid clsid,short langid,ref Guid profile,out bool enabled);
[ SecurityCritical ]
void EnableLanguageProfileByDefault(); //非执行!可能是错误的声明。
[ SecurityCritical ]
void SubstituteKeyboardLayout(); //非执行!可能是错误的声明。
}
[ ComImport,InterfaceType(ComInterfaceType .InterfaceIsIUnknown),
Guid(“3d61bf11-ac5f-42c8-a4cb-931bcc28c744”)]
内部 接口 IEnumTfLanguageProfiles
{
无效克隆(输出 IEnumTfLanguageProfiles enumIPP);
[ PreserveSig ]
int Next(int count,[ Out,MarshalAs(UnmanagedType .LPArray,SizeParamIndex = 2)]
TF_LANGUAGEPROFILE [] profiles,out int fetched);
无效重置();
无效跳过(int count);
}
内部 静态 类 TSF_NativeAPI
{
公共 静态 只读 guid GUID_TFCAT_TIP_KEYBOARD;
静态 TSF_NativeAPI()
{
GUID_TFCAT_TIP_KEYBOARD = 新的 Guid(0x34745c63,0xb2f0,
0x4784,0x8b,0x67,0x5e,0x12,200x,0x1a,0x31);
}
[ SecurityCritical,SuppressUnmanagedCodeSecurity,DllImport(“msctf.dll”)]
public static extern int TF_CreateInputProcessorProfiles(out ITfInputProcessorProfiles profiles);
}
}
|
|
public static short [] GetLangIDs()
{
List < short > langIDs = new List < short >();
ITfInputProcessorProfiles配置文件;
如果(TSF_NativeAPI .TF_CreateInputProcessorProfiles(out profiles)== 0)
{
IntPtr langPtrs;
int fetchCount = 0;
if(profiles.GetLanguageList(out langPtrs,out fetchCount)== 0)
{
for(int i = 0; i <fetchCount; i ++)
{
short id = Marshal .ReadInt16(langPtrs,sizeof(short)* i);
langIDs.Add(ID);
}
}
Marshal .ReleaseComObject(profiles);
}
返回 langIDs.ToArray();
}
public static string [] GetInputMethodList(short langID)
{
List < string > imeList = new List < string >();
ITfInputProcessorProfiles配置文件;
如果(TSF_NativeAPI .TF_CreateInputProcessorProfiles(out profiles)== 0)
{
尝试
{
IEnumTfLanguageProfiles enumerator = null ;
if(profiles.EnumLanguageProfiles(langID,out enumerator)== 0)
{
if(enumerator!= null)
{
TF_LANGUAGEPROFILE [] langProfile = new TF_LANGUAGEPROFILE [1];
int fetchCount = 0;
while(enumerator.Next(1,langProfile,out fetchCount)== 0)
{
IntPtr ptr;
if(profiles.GetLanguageProfileDescription(ref langProfile [0] .clsid,
langProfile [0] .langid,ref langProfile [0] .guidProfile,out ptr)== 0)
{
布尔启用;
if(profiles.IsEnabledLanguageProfile(ref langProfile [0] .clsid,
langProfile [0] .langid,ref langProfile [0] .guidProfile,out enabled)== 0)
{
如果(启用)
imeList.Add(Marshal .PtrToStringBSTR(ptr));
}
}
Marshal.FreeBSTR(ptr);
}
}
}
}
最后
{
Marshal .ReleaseComObject(profiles);
}
}
return imeList.ToArray();
}
|
|
私人短 [] langIDs;
………
private void button1_Click(object sender,EventArgs e)
{
langIDs = TSFWrapper .GetLangIDs();
如果(langIDs.Length> 0)
{
string [] list = TSFWrapper .GetInputMethodList(langIDs [0]);
的foreach(字符串递减的列表)
listBox1.Items.Add(降序);
}
}
|

|
public static bool ActiveInputMethodWithDesc(short langID,string desc)
{
ITfInputProcessorProfiles配置文件;
如果(TSF_NativeAPI .TF_CreateInputProcessorProfiles(out profiles)== 0)
{
尝试
{
IEnumTfLanguageProfiles enumerator = null ;
if(profiles.EnumLanguageProfiles(langID,out enumerator)== 0)
{
if(enumerator!= null)
{
TF_LANGUAGEPROFILE [] langProfile = new TF_LANGUAGEPROFILE [1];
int fetchCount = 0;
while(enumerator.Next(1,langProfile,out fetchCount)== 0)
{
IntPtr ptr;
if(profiles.GetLanguageProfileDescription(ref langProfile [0] .clsid,
langProfile [0] .langid,ref langProfile [0] .guidProfile,out ptr)== 0)
{
布尔启用;
if(profiles.IsEnabledLanguageProfile(ref langProfile [0] .clsid,
langProfile [0] .langid,ref langProfile [0] .guidProfile,out enabled)== 0)
{
如果(启用)
{
string s = Marshal .PtrToStringBSTR(ptr);
if(s.Equals(desc))
返回 profiles.ActivateLanguageProfile(参考 langProfile [0] .clsid,
langProfile [0] .langid,ref langProfile [0] .guidProfile)== 0;
}
}
Marshal.FreeBSTR(ptr);
}
}
}
}
}
最后
{
Marshal .ReleaseComObject(profiles);
}
}
返回 false ;
}
|
|
private void button2_Click(object sender,EventArgs e)
{
如果(langIDs!= null)
{
if(listBox1.SelectedIndex!= -1)
TSFWrapper .ActiveInputMethodWithDesc(langIDs [0],(string)listBox1.SelectedItem);
}
}
|
|
public static bool DeActiveInputMethod(short langID)
{
List < string > imeList = new List < string >();
ITfInputProcessorProfiles配置文件;
如果(TSF_NativeAPI .TF_CreateInputProcessorProfiles(out profiles)== 0)
{
尝试
{
Guid clsid = Guid .Empty;
返回 profiles.ActivateLanguageProfile(ref clsid,langID,ref clsid)== 0;
}
最后
{
Marshal .ReleaseComObject(profiles);
}
}
返回 false ;
}
|
VISTA 与输入法程式介面的更多相关文章
- C# TSF 输入法的获取
原文 C# TSF 输入法的获取 起因: 「添雨跟打器」中存在一个问题.在 windows 8/10 里面,输入法就获取不到了.我一直没有去管这样的问题.但是也大致知道,可能是 TSF 架构的问题. ...
- Backbone.js
Backbone.js是一套JavaScript框架與RESTful JSON的應用程式介面.也是一套大致上符合MVC架構的編程範型.Backbone.js以輕量為特色,只需依賴一套Javascrip ...
- LINUX诞生
编辑 Linux[1] 是一类Unix计算机操作系统的统称.Linux操作系统也是自由软件和开放源代码发展中最著名的例子.在1991 年的十月,由一个名为 Linus Torvalds的年轻芬兰大学 ...
- facebook api介绍
转自(http://sls.weco.net/node/10773) 一.Facebook API 基礎概念 Facebook API 概論 : API 最大的好處在於可以讓程式開發人員只需要根據 A ...
- PAM 認 證 模 組
作者:陳柏菁 E-mail 作用:限制哪些用户或者组可以从哪里登陆,或者可以建立/etc/nologin立即阻止一般用户登陆,限制 user可以使用的资源.例如cpu,文件,登陆数量,某些服务的登陆时 ...
- socket 中午吃的啥 socket 并发服务器 fork
http://www.cnblogs.com/thinksasa/archive/2013/02/26/2934206.html zh.wikipedia.org/wiki/網路插座 在作業系統中,通 ...
- 修改 /var/lib/locales/supported.d/local 文件(使用 locale -a 命令查看系统中所有已配置的 locale)
转自:http://zyxhome.org/wp/cc-prog-lang/c-stdlib-setlocale-usage-note/ http://www.west263.com/info/htm ...
- OpenCV之响应鼠标(二):函数cvSetMouseCallback()和其副程式onMouse()的使用(OpenCV2.4.5)
每當滑鼠在視訊視窗介面點擊一下的時候,都會有固定三個動作 1.點擊(Click) 2.放開(Down)3.滑動(move) 因此,程式執行滑鼠在點擊的時候onMouse()都會連續跑三次,代表滑鼠在點 ...
- Android InputMethodManager输入法简介
正文 一.结构 public final class InputMethodManager extends Object Java.lang.Object android.view.inputmeth ...
随机推荐
- [Angular Directive] Structure directive and <template>
The structure directive is just a sugar syntax of <template>. Such as: <div *ngIf="nam ...
- Hadoop源码分析(MapReduce概论)
大家都熟悉文件系统,在对HDFS进行分析前,我们并没有花非常多的时间去介绍HDFS的背景.毕竟大家对文件系统的还是有一定的理解的,并且也有非常好的文档.在分析Hadoop的MapReduce部分前,我 ...
- UTC时间与当地时间的转换关系?
UTC时间与当地时间转换关系? 一.总结 1.UTC +时区差=本地时间 2.UTC是世界统一时间 二.UTC时间是什么 1.UTC时间 协调世界时,又称世界统一时间.世界标准时间.国际协调时间.由于 ...
- 【u025】贝茜的晨练计划
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 奶牛们打算通过锻炼来培养自己的运动细胞,作为其中的一员,贝茜选择的运动方式是每天进行N(1 <= ...
- poj1066--Treasure Hunt(规范相交)
题目链接:点击打开链接 题目大意:一个正方形的墓葬内有n堵墙,每堵墙的两个顶点都在正方形的边界上,如今这些墙将墓葬切割成了非常多小空间,已知正方形内的一个点上存在宝藏,如今我们要在正方形的外面去得到宝 ...
- Linux网络编程——原始套接字能干什么?
通常情况下程序员接所接触到的套接字(Socket)为两类: (1)流式套接字(SOCK_STREAM):一种面向连接的 Socket,针对于面向连接的TCP 服务应用: (2)数据报式套接字(SOCK ...
- js如何实现点击显示和隐藏表格
js如何实现点击显示和隐藏表格 一.总结 一句话总结: 1.给table或者table里面的元素添加点击事件, 2.然后判断当前表格的数据显示或者隐藏, 3.然后通过display属性显示(非none ...
- Everything starts with a dream(A day has only 24 hours and these things take time,所以要抓紧)
There is the famous quote: "Everything starts with a dream" and many years ago, Michael Va ...
- uiwebview的常用属性1-故事版
- iOS 利用FZEasyFile本地保存 和 常规保存
1.常规保存(较麻烦) NSFileManager *fileManager = [NSFileManager defaultManager]; //获取document路径,括号中属性为当前应用程序 ...