zoukankan      html  css  js  c++  java
  • P/Invoke调用SipEnumIM枚举SIP失败?


    通过.NET CF本身提供的方法枚举设备中的所有SIP可以方便的完成这个问题。如下:
            // 定义一个InputPanel 
            private InputPanel m_inputPanel = new InputPanel();
            
            // 枚举SIP
            foreach (InputMethod method in m_inputPanel.InputMethods)
            {
                
    this.listBox.Items.Add(method.Name);
            }

    通过上面的方式枚举设备所有SIP后,就可以选择自己需要的SIP了
            private void SetNewSIP(string sipName)
            {
                
    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,也就是表示失败







     

    --------------------------------------------------

    李森 – listen
    E-mail:  lisencool@gmail.com

    声明:
    这里集中了在WinCEWindows Mobile开发中的一些基本常识。我很乐意和大家分享,也希望大家提出意见,并给我投稿,我会第一时间替您发表并署上您的大名!

    Announce:
    Here collects general knowledge on WinCE and Windows mobile. I 'm very glad to share them with all friends, and also hope you can share your problems and opinions and contribute articles to me to share with others. I'll publish your articles and sign your name at the first time.

      
  • 相关阅读:
    gzip格式解压缩
    震动效果
    用SDWebImage加载FLAnimatedImage
    用UIInterpolatingMotionEffect产生透视效果
    将CAGradientLayer当做mask使用
    UITableView加载网络数据的优化
    沿着path路径做动画
    vue入门案例
    springboot拦截器拦了静态资源css,js,png,jpeg,svg等等静态资源
    SpringBoot2.x|Thymeleaf页面不能正常载入css、js文件
  • 原文地址:https://www.cnblogs.com/Lisen/p/1568754.html
Copyright © 2011-2022 走看看