Using system;
Using system. Collections. Generic;
Using system. text;
Using system. runtime. interopservices;
Namespace mobilesp
{
Public class GMS
{
// Codego.net initializes the GSM Modem and connects to the GSM Modem
[Dllimport ("dllforvc. dll ",
Entrypoint = "gsmmodeminitnew ",
Charset = charset. ANSI,
Callingconvention = callingconvention. stdcall)]
Public static extern bool gsmmodeminitnew (
String device,
String baudrate,
String initstring,
String charset,
Bool swhandshake,
String Sn );
// Obtain the new ID number of the SMS cat
[Dllimport ("dllforvc. dll ",
Entrypoint = "gsmmodemgetsninfonew ",
Charset = charset. ANSI,
Callingconvention = callingconvention. stdcall)]
Public static extern string gsmmodemgetsninfonew (string device, string baudrate );
// Obtain the current communication port
[Dllimport ("dllforvc. dll ",
Entrypoint = "gsmmodemgetdevice ",
Charset = charset. ANSI,
Callingconvention = callingconvention. stdcall)]
Public static extern string gsmmodemgetdevice ();
// Get the current communication baud rate
[Dllimport ("dllforvc. dll ",
Entrypoint = "gsmmodemgetbaudrate ",
Charset = charset. ANSI,
Callingconvention = callingconvention. stdcall)]
Public static extern string gsmmodemgetbaudrate ();
// Disconnect and release memory space
[Dllimport ("dllforvc. dll ",
Entrypoint = "gsmmodemrelease ",
Charset = charset. ANSI,
Callingconvention = callingconvention. stdcall)]
Public static extern void gsmmodemrelease ();
// Get error message
[Dllimport ("dllforvc. dll ",
Entrypoint = "gsmmodemgeterrormsg ",
Charset = charset. ANSI,
Callingconvention = callingconvention. stdcall)]
Public static extern string gsmmodemgeterrormsg ();
// Send Short Message
[Dllimport ("dllforvc. dll ",
Entrypoint = "gsmmodemsmssend ",
Charset = charset. ANSI,
Callingconvention = callingconvention. stdcall)]
Public static extern bool gsmmodemsmssend (
String servicecenteraddress,
Int encodeval,
String text,
Int textlen,
String phonenumber,
Bool requeststatusreport );
// The returned string for receiving short messages is in the following format: Mobile Phone Number | SMS content | mobile phone number | SMS content | codego.net/tags/11/1/
// Rd_opt is 1 and will not be processed after receiving the short message. 0 indicates that the received message will be deleted.
[Dllimport ("dllforvc. dll ",
Entrypoint = "gsmmodemsmsreadall ",
Charset = charset. ANSI,
Callingconvention = callingconvention. stdcall)]
Public static extern string gsmmodemsmsreadall (INT rd_opt );
}
}
This article from the baboons literature baboons blog, please be sure to keep this http://9521583.blog.51cto.com/9511583/1570638
Encapsulate SMS cat, Dell class library generation, create a class library project in vs2008, and create a pulbic type GMS class in mobilesp.