110,580
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace order_system
{
public delegate int CallBack(int num);
public partial class MainInterface : Form
{
[DllImport("kernel32",EntryPoint="CopyMemory")]
public static extern void CopyMemory(System.IntPtr Dest, System.IntPtr Source, int Length);
[DllImport("Sandu.dll", EntryPoint = "Setup_Tel", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern void Setup_Tel(IntPtr fPost2User, int getall);
[DllImport("Sandu.dll", EntryPoint = "GetNumber_Tel", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetNumber_Tel(int port);
public static int GetNumber(int num)
{
IntPtr telAddress = GetNumber_Tel(64);
string telnumber = (Marshal.PtrToStringAuto(telAddress));
MessageBox.Show(telnumber);
IntPtr Tel = new IntPtr();
CopyMemory(Tel, telAddress, Marshal.SizeOf(telnumber));
return Convert.ToInt32(telnumber);
}
public MainInterface()
{
InitializeComponent();
IntPtr address = Marshal.GetFunctionPointerForDelegate(new CallBack(GetNumber));
Setup_Tel(address, 0);
}
private void MainInterface_Load(object sender, System.EventArgs e)
{
}
}
}
public delegate void StateEventCallBack(uint state);
public class TelApi
{
[DllImport("Sandu.dll")]
public static extern void Setup_Tel(StateEventCallBack callback, bool getAll);
[DllImport("Sandu.dll")]
public static extern int Begin_Tel(int port, char powerChar);
[DllImport("Sandu.dll")]
public static extern int End_Tel(int port);
[DllImport("Sandu.dll")]
public static extern string GetNumber_Tel(int port);
[DllImport("Sandu.dll")]
public static extern int Dial_Tel(int port, string numbers);
[DllImport("Sandu.dll")]
public static extern int Hookup_Tel(int port, bool flag);
[DllImport("Sandu.dll")]
public static extern bool LineOffHook_Tel(int port);
[DllImport("Sandu.dll")]
public static extern bool Plugin_Tel(int port);
[DllImport("Sandu.dll")]
public static extern bool ISRing_Tel(int port);
[DllImport("Sandu.dll")]
public static extern int DevCount_Tel();
[DllImport("Sandu.dll")]
public static extern int GetDevMode_Tel(int dev);
[DllImport("Sandu.dll")]
public static extern bool ChangeDevMode_Tel(int dev, int mode);
[DllImport("Sandu.dll")]
public static extern int Check_State(int port);
}