TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kenfack Cathy
NA
19
603
application d'envoie sms en C# determiner le num d port COM
Apr 17 2020 7:12 AM
BONJOUR , JE DEVELOPE UNE Application d'envoie sms par modem gsm en c# et j'aimerai savoir comment determiner le numero du port COM utiliser par mon moderm une fois qu'il est connecte a mon ordinateur, enfaite il me faut entre ce numero dans le code merci.
Voici mon code complet j'ai mis au niveau de com xx par ce que je n'ai pas de numero
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.IO.Ports;
using
System.Linq;
using
System.Text;
using
System.Threading;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
TP1_SMS
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
label5_Click(
object
sender, EventArgs e)
{
}
private
void
button3_Click(
object
sender, EventArgs e)
{
SerialPort sp =
new
SerialPort();
sp.PortName =
"COMXX"
;
sp.Open();
sp.WriteLine(
"AT"
+ Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine(
"AT+CMGF= 1 "
+ Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine(
"AT+CSCS=\"GSM\""
+ Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine(
"AT+CMGS=\""
+ textBox5.Text +
"\" "
+ Environment.NewLine);
//CONTACT
Thread.Sleep(100);
sp.WriteLine(textBox6.Text + Environment.NewLine);
//MESSAGE
Thread.Sleep(100);
sp.Write(
new
byte
[] { 26 }, 0, 1);
Thread.Sleep(100);
var response = sp.ReadExisting();
if
(response.Contains(
"ERROR"
))
{
MessageBox.Show(
"Failed!"
,
"FAILED"
, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show(
"Sent"
,
"SUCCESS"
, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
sp.Close();
}
}
}
Reply
Answers (
1
)
quetion related api
hi Team, the below pic shows date which i am gett