2,089
社区成员
发帖
与我相关
我的任务
分享
const int S_OK = 0;
const uint CONNMGR_PARAM_GUIDDESTNET = 0x1;
const uint CONNMGR_PRIORITY_USERINTERACTIVE = 0x08000;
const uint INFINITE = 0xffffffff;
const uint CONNMGR_STATUS_CONNECTED = 0x10;
const int CONNMGR_MAX_DESC = 128; // @constdefine Max size of a network description
const int CONNMGR_FLAG_PROXY_HTTP = 0x1; // @constdefine HTTP Proxy supported
const int CONNMGR_FLAG_PROXY_WAP = 0x2; // @constdefine WAP Proxy (gateway) supported
const int CONNMGR_FLAG_PROXY_SOCKS4 = 0x4; // @constdefine SOCKS4 Proxy supported
const int CONNMGR_FLAG_PROXY_SOCKS5 = 0x8; // @constdefine SOCKS5 Proxy supported
const UInt16 IDC_WAIT = 32514;
const UInt16 IDC_ARROW = 32512;
[StructLayout(LayoutKind.Sequential)]
public struct CONNMGR_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;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CONNMGR_DESTINATION_INFO
{
public GUID guid; // @field GUID associated with network
[MarshalAs(UnmanagedType.ByValTStr,SizeConst = CONNMGR_MAX_DESC)]
public string szDescription; // @field Description of network
public int fSecure; // @field Is it OK to allow multi-homing on the network
}
public struct GUID
{ // size is 16
public uint Data1;
public UInt16 Data2;
public UInt16 Data3;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] Data4;
}
[DllImport("coredll.dll")]
public static extern uint GetTickCount();
[DllImport("coredll.dll")]
public static extern uint WaitForSingleObject(IntPtr hHandle,uint dwMilliseconds);
[DllImport("cellcore.dll")]
public static extern int ConnMgrMapURL(string pwszURL, ref GUID pguid, ref uint pdwIndex);
[DllImport("cellcore.dll")]
public static extern int ConnMgrEstablishConnectionSync(ref CONNMGR_CONNECTIONINFO ci, ref IntPtr phConnection, uint dwTimeout, ref uint pdwStatus);
[DllImport("cellcore.dll")]
private static extern IntPtr ConnMgrApiReadyEvent();
[DllImport("cellcore.dll")]
public static extern int ConnMgrReleaseConnection(IntPtr hConnection, int bCache);
[DllImport("cellcore.dll")]
public static extern int ConnMgrEnumDestinations(int nIndex,ref CONNMGR_DESTINATION_INFO pDestInfo);
[DllImport("cellcore.dll")]
public static extern int ConnMgrConnectionStatus(IntPtr hConnection, // @parm Handle to connection, returned from ConnMgrEstablishConnection
ref uint pdwStatus // @parm Returns current connection status, one of CONNMGR_STATUS_*
);
[DllImport("coredll.dll")]
private static extern int CloseHandle(IntPtr hObject);