通过.NET CF本身提供的方法枚举设备中的所有SIP可以方便的完成这个问题。如下:
//
定义一个InputPanel
private InputPanel m_inputPanel = new InputPanel();
// 枚举SIP
foreach (InputMethod method in m_inputPanel.InputMethods)
{
this .listBox.Items.Add(method.Name);
}
private InputPanel m_inputPanel = new InputPanel();
// 枚举SIP
foreach (InputMethod method in m_inputPanel.InputMethods)
{
this .listBox.Items.Add(method.Name);
}
通过上面的方式枚举设备所有SIP后,就可以选择自己需要的SIP了
参考:
http://msdn.microsoft.com/en-us/library/microsoft.windowsce.forms.inputpanel.currentinputmethod.aspx
private
void
SetNewSIP(
string
sipName)
{
foreach (InputMethod method in m_inputPanel.InputMethods)
{
if (sipName.Equals(method.Name))
{
m_inputPanel.CurrentInputMethod = method;
break ;
}
}
}
{
foreach (InputMethod method in m_inputPanel.InputMethods)
{
if (sipName.Equals(method.Name))
{
m_inputPanel.CurrentInputMethod = method;
break ;
}
}
}
参考:
ASK:
我想P/Invoke系统API来实现.NET CF为我们实现的枚举功能,如下代码,但是总是返回0,也就是没有枚举到,请问,是我的结构体参数设置错误还是其他呢?
public
class
SIPManager
{
public delegate int IMENUMPROC( ref IMENUMINFO IMinfo);
[DllImport( " coredll.dll " )]
public static extern int SipEnumIM(IMENUMPROC EnumIMProc);
private List < IMENUMINFO > SIPs = new List < IMENUMINFO > ();
public int SipEnumIMProc( ref IMENUMINFO IMinfo)
{
SIPs.Add(IMinfo);
return 1 ;
}
public List < IMENUMINFO > GetSIPs()
{
int imcount = SipEnumIM(SipEnumIMProc);
return SIPs;
}
public class IMENUMINFO
{
public StringBuilder szName;
public Guid clsid;
public IMENUMINFO()
{
szName = new StringBuilder();
clsid = new Guid();
}
}
}
// 按照下面方式调用
SIPManager sipmgr = new SIPManager();
List < SIPManager.IMENUMINFO > list = new List < SIPManager.IMENUMINFO > ();
list = sipmgr.GetSIPs();
// 但是每次跟踪进GetSIPs之后,里面imcount返回值总为0,也就是表示失败
{
public delegate int IMENUMPROC( ref IMENUMINFO IMinfo);
[DllImport( " coredll.dll " )]
public static extern int SipEnumIM(IMENUMPROC EnumIMProc);
private List < IMENUMINFO > SIPs = new List < IMENUMINFO > ();
public int SipEnumIMProc( ref IMENUMINFO IMinfo)
{
SIPs.Add(IMinfo);
return 1 ;
}
public List < IMENUMINFO > GetSIPs()
{
int imcount = SipEnumIM(SipEnumIMProc);
return SIPs;
}
public class IMENUMINFO
{
public StringBuilder szName;
public Guid clsid;
public IMENUMINFO()
{
szName = new StringBuilder();
clsid = new Guid();
}
}
}
// 按照下面方式调用
SIPManager sipmgr = new SIPManager();
List < SIPManager.IMENUMINFO > list = new List < SIPManager.IMENUMINFO > ();
list = sipmgr.GetSIPs();
// 但是每次跟踪进GetSIPs之后,里面imcount返回值总为0,也就是表示失败
--------------------------------------------------
李森 – listen |
声明: Announce: |