1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace GetPhoneNumber { public partial class Form1 : Form { public static string FromUnicodeByteArray(byte[] characters) { UnicodeEncoding u = new UnicodeEncoding(); string ustring = u.GetString(characters); return ustring; }
public static string FromASCIIByteArray(byte[] characters) { ASCIIEncoding encoding = new ASCIIEncoding(); string constructedString = encoding.GetString(characters); return (constructedString); }
public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { if (BriSDKLib.QNV_OpenDevice(BriSDKLib.ODT_LBRIDGE, 0, "") <= 0 || BriSDKLib.QNV_DevInfo(0, BriSDKLib.QNV_DEVINFO_GETCHANNELS) <= 0) { // AppendStatus("打开设备失败"); MessageBox.Show("打开设备失败"); return; } for (Int16 i = 0; i < BriSDKLib.QNV_DevInfo(-1, BriSDKLib.QNV_DEVINFO_GETCHANNELS); i++) { //在windowproc处理接收到的消息 BriSDKLib.QNV_Event(i, BriSDKLib.QNV_EVENT_REGWND, (Int32) this.Handle, "", new StringBuilder(0), 0); // selchannel.Items.Add(i+1); } }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { BriSDKLib.QNV_CloseDevice(BriSDKLib.ODT_ALL, 0); for (Int16 i = 0; i < BriSDKLib.QNV_DevInfo(-1, BriSDKLib.QNV_DEVINFO_GETCHANNELS); i++) { //在windowproc处理接收到的消息 BriSDKLib.QNV_Event(i, BriSDKLib.QNV_EVENT_REGWND, (Int32) this.Handle, "", new StringBuilder(0), 0); // selchannel.Items.Add(i+1); } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case BriSDKLib.BRI_EVENT_MESSAGE: { BriSDKLib.TBriEvent_Data EventData = (BriSDKLib.TBriEvent_Data) Marshal.PtrToStructure(m.LParam, typeof(BriSDKLib.TBriEvent_Data)); string strValue = ""; switch (EventData.lEventType) { case BriSDKLib.BriEvent_GetCallID: { strValue = "通道" + (EventData.uChannelID + 1).ToString() + ":接收到来电号码 " + FromASCIIByteArray(EventData.szData); MessageBox.Show(strValue); this.Activate();
} break; default: break; } } break; default: base.DefWndProc(ref m); break; } }
private void 退出XToolStripMenuItem_Click(object sender, EventArgs e) { BriSDKLib.QNV_CloseDevice(BriSDKLib.ODT_ALL, 0); for (Int16 i = 0; i < BriSDKLib.QNV_DevInfo(-1, BriSDKLib.QNV_DEVINFO_GETCHANNELS); i++) { //在windowproc处理接收到的消息 BriSDKLib.QNV_Event(i, BriSDKLib.QNV_EVENT_REGWND, (Int32) this.Handle, "", new StringBuilder(0), 0); // selchannel.Items.Add(i+1); } Application.Exit(); }
private void Form1_Shown(object sender, EventArgs e) { Hide(); } } }
|