当前位置:编程学习 > C#/ASP.NET >>

如何使用TapiLib.dll

 我要在下面的代码中使用TapiLib.dll ,因为里面有Tapi和Line类: 
怎么办??? 
public   struct   GeneralInfo 
        { 
                public   string   Manufacturer;//制造商 
                public   string   Model;//机型 
                public   string   Revision;//版本 
                public   string   SerialNumber;//序列号 
                public   string   SubscriberNumber;//用户电话 
        } 

        class   ControlTapi 
        { 
                
                [DllImport("cellcore.dll")] 
                private   static   extern   int   lineGetGeneralInfo(IntPtr   hLine,   byte[]   lpLineGeneralInfo); 
                  ///   <summary> 
                ///   调用cellcore.dll获取sim卡的综合信息 
                ///   </summary> 
                ///   <param   name="l"> </param> 
                ///   <returns> </returns> 
                private   GeneralInfo   GetGeneralInfo(Line   l) 
                { 
                        GeneralInfo   lgi   =   new   GeneralInfo(); 
                        byte[]   buffer   =   new   byte[512]; 
                        BitConverter.GetBytes(512).CopyTo(buffer,   0); 

                        if   (lineGetGeneralInfo(l.hLine,   buffer)   !=   0) 
                        { 
                                throw   new   System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(),   "TAPI   Error:   "   +   System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X")); 
                        } 
                        
                        int   subscsize   =   BitConverter.ToInt32(buffer,   44); 
                        int   subscoffset   =   BitConverter.ToInt32(buffer,   48); 
                        lgi.SubscriberNumber   =   System.Text.Encoding.Unicode.GetString(buffer,   subscoffset,   subscsize).ToString(); 
                        lgi.SubscriberNumber   =   lgi.SubscriberNumber.Replace("\0",   ""); 
                        return   lgi; 

                } 


                ///   <summary> 
                ///   获取sim卡的IMSI 
                ///   </summary> 
                ///   <returns> </returns> 
                ///   一个imsi   (国际移动用户识别)是一个独特的15位数字代码用于识别个人用户对GSM网络。   
                ///An   IMSI   consists   of   three   components:一个imsi包括三个组成部分:   
                ///Mobile   Country   Code   (MCC)移动国家代码(   MCC   )的   
                ///Mobile   Network   Code   (MNC)移动网络代码(跨国公司)   
                ///Mobile   Subscriber   Identity   Number   (MSIN)移动用户识别号码(   msin   )   

                public   static   string   GetIMSINumber() 
                { 
                        string   result   =   ""; 
                        try 
                        { 
                                Tapi   t   =   new   Tapi();                                 t.Initialize(); 
                                Line   l   =   t.CreateLine(0,   LINEMEDIAMODE.INTERACTIVEVOICE,   OpenNETCF.Tapi.LINECALLPRIVILEGE.MONITOR);                                 ControlTapi   ctapi   =   new   ControlTapi(); 
                                GeneralInfo   gi   =   ctapi.GetGeneralInfo(l); 
                                
                                result   =   gi.SubscriberNumber; 
                                l.Dispose(); 
                                t.Shutdown(); 

                        } 
                        catch//   (Exception   ex) 
                        { 
                                result   =   ""; 
                        } 

                        return   result; 

                } 

                ///   <summary> 
                ///   获取IMEI的号码 
                ///   </summary> 
                ///   <returns> </returns> 
                ///   移动通信国际识别码(International   Mobile   Equipment   Identity   number),由15位数字组成,用于在手机网络中识别每一部独立的手机。相当于移动电话的身份证。每组移动通信国际识别码都有15个易做图数字,并且前6码为原制造厂编码,中间8码为“流水号”,最后1码为备用码。移动通信国际识别码的每一码所出现的数字均起到移动电话身分辨正的功能,并且是国际上公认通的共享数码准则。 
                ///唯一标识某个移动设备的数字。IMEI   位于手机背面的标签上。当网络请求时,手机会自动传送该标识。   

                public   static   string   GetIMEINumber() 
                { 
                        string   result   =   ""; 
                        try 
                        { 
                                Tapi   t   =   new   Tapi();                                 t.Initialize(); 
                                Line   l   =   t.CreateLine(0,   LINEMEDIAMODE.INTERACTIVEVOICE,   OpenNETCF.Tapi.LINECALLPRIVILEGE.MONITOR);                                 ControlTapi   ctapi   =   new   ControlTapi(); 
                                GeneralInfo   gi   =   ctapi.GetGeneralInfo(l); 
                                result   =   gi.SerialNumber; 
                                l.Dispose(); 
                                t.Shutdown(); 

                        } 
                        catch//   (Exception   ex) 
                        { 
                                result   =   ""; 
                        } 

                        return   result; 
                }

--------------------编程问答-------------------- 上面代码有错误? --------------------编程问答-------------------- 没有啊.
TapiLib.dll 怎么用,因为里面有Tapi和Line类:  
--------------------编程问答-------------------- 把dll文件添加到项目中,在项目上右键,添加引用,浏览,选择dll添加,然后想怎么用就怎么用 --------------------编程问答-------------------- 有人解决吗这个问题,我也需要答案 --------------------编程问答-------------------- 行不行啊?????????
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,