WEB开发网
开发学院手机开发Windows Mobile 开发 Windows Mobile上的GPRS连接 基于TcpClient 阅读

Windows Mobile上的GPRS连接 基于TcpClient

 2010-05-06 21:56:00 来源:WEB开发网   
核心提示:ci.uMsg = 0;ci.lParam = 0;if (ConnMgrEstablishConnectionSync(ref ci, ref phConnection, INFINITE, ref status) != S_OK &&status != CONNMGR_STATUS_CONNECTED)return

ci.uMsg = 0;

ci.lParam = 0;

if (ConnMgrEstablishConnectionSync(ref ci, ref phConnection, INFINITE, ref status) != S_OK &&

status != CONNMGR_STATUS_CONNECTED)

return false;

ht[urlStr] = phConnection;

return true;

}

public static bool Release(Uri url)

{

return Release(url.ToString());

}

public static bool Release(string urlStr)

{

return Release(urlStr, true);

}

private static bool Release(string urlStr, bool removeNode)

{

bool res = true;

IntPtr ph = IntPtr.Zero;

if (ht[urlStr] == null)

return true;

ph = (IntPtr)ht[urlStr];

if (ConnMgrReleaseConnection(ph, 1) != S_OK)

res = false;

CloseHandle(ph);

if (removeNode)

ht.Remove(urlStr);

return res;

}

public static void ReleaseAll()

{

foreach(DictionaryEntry de in ht)

{

Release((string)de.Key, false);

}

ht.Clear();

}

[StructLayout(LayoutKind.Sequential)]

public struct ConnectionInfo

{

public uint cbSize;

public uint dwParams;

public uint dwFlags;

public uint dwPriority;

public int bExclusive;

public int bDisabled;

public Guid guidDestNet;

public IntPtr hWnd;

public uint uMsg;

public uint lParam;

public uint ulMaxCost;

public uint ulMinRcvBw;

public uint ulMaxConnLatency;

}

[DllImport("cellcore.dll")]

private static extern int ConnMgrMapURL(string pwszURL, ref Guid pguid, IntPtr pdwIndex);

[DllImport("cellcore.dll")]

private static extern int ConnMgrEstablishConnectionSync(ref ConnectionInfo

Tags:Windows Mobile GPRS

编辑录入:coldstar [复制链接] [打 印]
赞助商链接