尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
[STAThread] [DllImport("sms.dll", EntryPoint = "Sms_Connection")]
public static extern uint Sms_Connection(uint Com_Port, uint Com_BaudRate, out string Mobile_Type); [DllImport("sms.dll", EntryPoint = "Sms_Disconnection")]
public static extern uint Sms_Disconnection(); [DllImport("sms.dll", EntryPoint = "Sms_Send")]
public static extern uint Sms_Send(string Sms_TelNum, string Sms_Text); [DllImport("sms.dll", EntryPoint = "Sms_Receive")]
public static extern uint Sms_Receive(string Sms_Type, out string Sms_Text); [DllImport("sms.dll", EntryPoint = "Sms_Delete")]
public static extern uint Sms_Delete(string Sms_Index); [DllImport("sms.dll", EntryPoint = "Sms_AutoFlag")]
public static extern uint Sms_AutoFlag(); [DllImport("sms.dll", EntryPoint = "Sms_NewFlag")]
public static extern uint Sms_NewFlag();
//如果连接成功返回true 否则返回false
public bool SmsConn()
{
try
{
string TypeStr = "";
if (Sms_Connection(uint.Parse(AddResource.SMSPORT), 9600, out TypeStr) == 1) ///5为串口号,0为红外接口,1,2,3,...为串口
{
return true;
}else {
return false;
}
}catch (Exception) {
return false;
}
}
[STAThread] [DllImport("sms.dll", EntryPoint = "Sms_Connection")]
public static extern uint Sms_Connection(uint Com_Port, uint Com_BaudRate, out string Mobile_Type); [DllImport("sms.dll", EntryPoint = "Sms_Disconnection")]
public static extern uint Sms_Disconnection(); [DllImport("sms.dll", EntryPoint = "Sms_Send")]
public static extern uint Sms_Send(string Sms_TelNum, string Sms_Text); [DllImport("sms.dll", EntryPoint = "Sms_Receive")]
public static extern uint Sms_Receive(string Sms_Type, out string Sms_Text); [DllImport("sms.dll", EntryPoint = "Sms_Delete")]
public static extern uint Sms_Delete(string Sms_Index); [DllImport("sms.dll", EntryPoint = "Sms_AutoFlag")]
public static extern uint Sms_AutoFlag(); [DllImport("sms.dll", EntryPoint = "Sms_NewFlag")]
public static extern uint Sms_NewFlag();
//如果连接成功返回true 否则返回false
public bool SmsConn()
{
try
{
string TypeStr = "";
if (Sms_Connection(uint.Parse(AddResource.SMSPORT), 9600, out TypeStr) == 1) ///5为串口号,0为红外接口,1,2,3,...为串口
{
return true;
}else {
return false;
}
}catch (Exception) {
return false;
}
}
public bool SmsConn()
{
try
{
string TypeStr = "";
if (Sms_Connection(uint.Parse(AddResource.SMSPORT), 9600, out TypeStr) == 1) ///5为串口号,0为红外接口,1,2,3,...为串口
{
return true;
}else {
return false;
}
}catch (Exception) {
return false;
}
}抛出的异常是 AcessViolationException
尝试读取或写入受保护的内存。这通常指示其他内存已损坏。