⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 GSM 模块软件开发包 开发包说明 开发包基于GSM模块开发
💻 CS
字号:
using System;
using System.Threading;

using System.Runtime.InteropServices; // DllImport所在的名字空间
unsafe public class AscendSMS 
{
	[DllImport("AscendSMS.dll")]	public static extern int OpenComm(int x);
	[DllImport("AscendSMS.Dll")]	public static extern int CloseComm(int x);
	[DllImport("AscendSMS.Dll")]	public static extern int SendMsg(int ComIndex,string Msg,string Mobile,int Msg_Index,bool Chinese);
	[DllImport("AscendSMS.Dll")]	public static extern bool GetSCA(int ComIndex,char* SCA);
	[DllImport("AscendSMS.Dll")]	public static extern bool GetNewMsg(int ComIndex,char* NewMsg);
	[DllImport("AscendSMS.Dll")]	public static extern int GetUnSendCount(int ComIndex);
	[DllImport("AscendSMS.Dll")]	public static extern bool SetSCA(int ComIndex,string SCA);
	[DllImport("AscendSMS.Dll")]	public static extern bool GetFailedMsg(int ComIndex,char* Msg);
	[DllImport("AscendSMS.Dll")]	public static extern bool GetNextSendMsg(int ComIndex,char* Msg,bool DeleteAfterRead);
	[DllImport("AscendSMS.Dll")]	public static extern int ForceCloseComm(int ComIndex);
	[DllImport("AscendSMS.Dll")]	public static extern bool GetSerialNo(int ComIndex,char*SerialNo);
}
namespace ConsoleApplication1
{

	class Welcome
	{
	
		unsafe static void Main()
		{
	
			char* tempchar=stackalloc char[100];
			byte* tempbyte=stackalloc byte[100];
			for (int i=0;i<100;i++)
			{
				tempbyte[i]=(byte)'\x0';
			}

			int rtn=AscendSMS.OpenComm(1);
			if(rtn==0)
			{
				Console.WriteLine("Open success!");
				Console.Write("GetSCA:");

				Thread.Sleep(1000);

				bool brtn=AscendSMS.GetSCA(1,(char*)tempbyte);

				for(int i=0;i<100;i++)
				{
					if(tempbyte[i]==(byte)('\x0'))
						break;
					Console.Write("{0}",(char)tempbyte[i]);
				}
				Console.WriteLine("\nFinish!");
				//				AscendSMS.SendMsg(1,"Hi Yale","13958002360",1,false);
			}
			if(rtn!=0)
				Console.WriteLine("Open Fail!");
			for(int i=0;i<5;i++)
			{
				Thread.Sleep(1000);
			}
			AscendSMS.CloseComm(1);

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -