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
IntPtr
desc);
[
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
;
}
|

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
-
上一篇
【c#】6.0与7.0新特性介绍记录
c#发展史 引用地址:https://www.cnblogs.com/ShaYeBlog/p/3661424.html 6.0新特性 1.字符串拼接优化 语法格式:$”string {参数}” 解释:以$符号开头开始字符串,其中以{}来进行传参,可以多个参数累加 例如:var results = $"Hello {Name}"; 2.null检测运算符 语法格式:【?.】 解释:需要判断的对象值后面跟随?号符号直接进行判断是否为空,然后条件不为空后需要执行的在“.”之后执行 例如: Program pro = new Program(); Console.WriteLine(pro?.GetCnblogsSite()); public string GetCnblogsSite() { return "http://www.cnblogs.com/yanbigfeg"; } 3.自动化属性 语法格式:attribute{get;set}=""; 解释:对象属性后面直接可以进行赋值操作。像普通赋值一样。 例如:publicstringname {g...
-
下一篇
APP收款语音播报功能讲解
一、背景 比起主动扫码能确定收款多少与是否到账,扫二维码支付场景不能直接确认,需要核对客户付款截屏,目前微信、支付宝在扫二维码支付后,均支持收款方自动播报收款到账信息,为了秦丝APP有更好体验,也需要加入该功能。 二、方案 目前实现的收款语音播报功能采用片段组合读音的方案,简单的解释就是根据收款的金额,提取相应数值语音播报,分别包括0-9,十-亿及一些单位或者标注发音等19个语音文件。比起传统语音合成方案,无需幅度增加app的大小,灵活控制语速。 三、实现 1、触发:在收到收款单号推送后,请求收款金额 2、解析:根据收款金额,解析成一个语音文件对象的数组以999999.99为例,拆解小数点左右两边部分后分开解析,小数点左边部分又以万为单位拆分,先解析万以内数字,然后再讲万以上的部分又当成万以内的解析加万语音片段,亿、兆类似。小数点后面的部分则从不加单位解析。 // 获取数字转语音文件的队列 function getArrayByNumber(num) { num = num + ""; if (/^(0|[1-9]\d*)(.\d*[1-9])?$/.test(num)) { var ...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS6,7,8上安装Nginx,支持https2.0的开启
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- Red5直播服务器,属于Java语言的直播服务器
- SpringBoot2全家桶,快速入门学习开发网站教程
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- SpringBoot2更换Tomcat为Jetty,小型站点的福音
- CentOS8编译安装MySQL8.0.19
- MySQL数据库在高并发下的优化方案
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池