散分.....................................................+Gprs讨论

ericzhangbo1982111 2008-06-30 11:11:39
Gprs 可以通过什么方式来连接

1.OpenNetCF中的System.Net类

2.WindowsApi
unsafe public static uint myRasDial(string EntryName,string

UserName,string Password,out IntPtr RasConn) {

/*

EntryName ,UserName,Password - same as in RASDIALPARAMS structure (see

MSDN)

*/

uint r=0;

RasConn=IntPtr.Zero;

byte[] bRASDIALPARAMS =new byte[1464];

fixed (byte* pAddr = bRASDIALPARAMS) {

byte* pCurrent = pAddr;

Marshal.WriteInt32((IntPtr)pCurrent,bRASDIALPARAMS.Length);

pCurrent+=4;

foreach (byte b in Encoding.Unicode.GetBytes(EntryName)) {

Marshal.WriteByte((IntPtr)pCurrent, b);

pCurrent++;

}

pCurrent=pAddr+0x192;//0x192 - offset for RASDIALPARAMS.UserName

foreach (byte b in Encoding.Unicode.GetBytes(UserName)) {

Marshal.WriteByte((IntPtr)pCurrent, b);

pCurrent++;

}

pCurrent=pAddr+0x394;//0x394 - offset for RASDIALPARAMS.Password

foreach (byte b in Encoding.Unicode.GetBytes(Password)) {

Marshal.WriteByte((IntPtr)pCurrent, b);

pCurrent++;

}

r=RasDial(IntPtr.Zero,IntPtr.Zero,(IntPtr)pAddr,0,IntPtr.Zero,ref

RasConn);

}

return r;

}

[DllImport("coredll.dll")]

public static extern uint RasDial(IntPtr dialExtensions,IntPtr

phoneBookPath,IntPtr rasDialParam,uint NotifierType,

IntPtr notifier, ref IntPtr pRasConn);

[DllImport("coredll.dll")]

public static extern uint RasHangUp(IntPtr pRasConn);

//------------------------------------------------------------------------

Example of using myRasDial

IntPtr rc; // connection handle

if(myRasDial("BeelineGPRS","beeline","beeline",out rc)==0) { //success

try {

TcpClient client = new TcpClient("www.someaddress.com", someport);

MessageBox.Show("OK");

//..................................

}

catch(Exception ex) {

MessageBox.Show(ex.Message);

}

RasHangUp(rc);

}

3.HttpWebRequest


4.不知道了。
...全文
115 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
slin60 2008-07-10
  • 打赏
  • 举报
回复
拿42分来散。。。。。。
hackztx 2008-07-10
  • 打赏
  • 举报
回复
unsafe 还没用过。。
bbbbbb888888 2008-07-10
  • 打赏
  • 举报
回复
jf
Tracy5453 2008-07-10
  • 打赏
  • 举报
回复
JF+STUDY
songyingjian2008 2008-07-09
  • 打赏
  • 举报
回复
学习
yatobiaf 2008-07-09
  • 打赏
  • 举报
回复
学习+接分
baihe_591 2008-07-09
  • 打赏
  • 举报
回复
MARK
ericzhangbo1982111 2008-07-09
  • 打赏
  • 举报
回复
仔细看了一下发的帖子 ,居然复制错了

红色字体的部分是连接gprs的拨号

还有连接的api也补上

[DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention = CallingConvention.Winapi)]
internal unsafe static extern int ConnMgrEstablishConnection(CONNMGR_CONNECTIONINFO pConnInfo, out IntPtr hConnection);

[DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention = CallingConvention.Winapi)]
internal unsafe static extern int ConnMgrReleaseConnection(IntPtr hConnection, int bCache);

[DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention = CallingConvention.Winapi)]
internal unsafe static extern int ConnMgrMapURL(string url, ref Guid guid, int* nIndex);

[DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal unsafe static extern int ConnMgrEstablishConnectionSync(CONNMGR_CONNECTIONINFO pConnInfo, out IntPtr hConn, uint timeout, ref uint status);

[DllImport("cellcore.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal unsafe static extern int ConnMgrConnectionStatus(IntPtr hConnection, uint* status);

wince的代码
baihe_591 2008-07-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ericzhangbo1982111 的回复:]
再等一天,没人就结帐了。
[/Quote]

别,学习+接分
yourlass 2008-07-09
  • 打赏
  • 举报
回复
GPRS 可以直接使用 WebService ,直接设计 Webservice 用c# 调用!就可以使用 GPRS 但是 GPRS 必须使用 CMNET 接入点
ericzhangbo1982111 2008-07-09
  • 打赏
  • 举报
回复
再等一天,没人就结帐了。
Adechen 2008-07-09
  • 打赏
  • 举报
回复
路过,来学习来了..,顺便接分
烈火焚身 2008-06-30
  • 打赏
  • 举报
回复
jf
大腹 2008-06-30
  • 打赏
  • 举报
回复
来学习来了..

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧