tapi.dll错误消息 [英] tapi.dll error message

查看:278
本文介绍了tapi.dll错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



类型'OpenNETCF.Tapi.LINEINITIALIZEEXPARAMS'不能作为非托管结构封送;不能计算有意义的大小或偏移量。 plz帮助以上错误。感谢提前。

Hi Friends,

Type 'OpenNETCF.Tapi.LINEINITIALIZEEXPARAMS' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed. plz help for above error. Thanks for advance.

推荐答案

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenNETCF.Tapi;
using System.Runtime.InteropServices ;


public partial class Mobile_mSource_Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string myIMEIstring = getIMEIInfo();
        Label2.Text = "Mobile Number:" + myIMEIstring;
    }

    [DllImport("cellcore.dll")]
    internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);

    // code to get IMEI
    private string getIMEIInfo()
    {
        string IMEI;
        Tapi t = new Tapi();
        t.Initialize();
        Line _line = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, LINECALLPRIVILEGE.MONITOR);

        byte[] buffer = new byte[512];
        //write size
        BitConverter.GetBytes(512).CopyTo(buffer, 0);

        if (lineGetGeneralInfo(_line.hLine, buffer) != 0)
        {
            throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), "TAPI Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X"));
        }

        int serialsize = BitConverter.ToInt32(buffer, 36);
        int serialoffset = BitConverter.ToInt32(buffer, 40);
        IMEI = System.Text.Encoding.Unicode.GetString(buffer, serialoffset, serialsize);
        IMEI = IMEI.Substring(0, IMEI.IndexOf(Convert.ToChar(0)));


        _line.Dispose();
        t.Shutdown();
        return (IMEI);
    }
}


这篇关于tapi.dll错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆