/// <summary> /// 查询主机在线状态,0表示未分配1表示离线2表示在线 /// </summary> /// <param name="_LoginID"></param> /// <returns></returns> public Dictionary <int, string> GetConnectionStatus(IntPtr _LoginID) { Dictionary <int, string> dic = new Dictionary <int, string>(); NET_IN_GETCONNECTION_STATUS stuinfo = new NET_IN_GETCONNECTION_STATUS() { dwSize = (uint)Marshal.SizeOf(typeof(NET_IN_GETCONNECTION_STATUS)), }; NET_OUT_GETCONNECTION_STATUS stuOutInfo = new NET_OUT_GETCONNECTION_STATUS() { dwSize = (uint)Marshal.SizeOf(typeof(NET_OUT_GETCONNECTION_STATUS)), }; bool result = NETClient.GetConnectionStatus(_LoginID, stuinfo, ref stuOutInfo, 3000); if (!result) { Console.WriteLine("GetConnectionStatus 失败"); Console.WriteLine("失败错误码,error:{0}", NETClient.GetLastError()); dic.Add(-1, "获取失败"); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("GetConnectionStatus 成功,nStatus-----0:未分配1:离线2:在线"); for (int i = 0; i < stuOutInfo.nChannelNum; ++i) { dic.Add(i, stuOutInfo.nStatus[i].ToString()); } } return(dic); }
public static extern bool CLIENT_GetConnectionStatus(IntPtr lLoginID, ref NET_IN_GETCONNECTION_STATUS pInParam, ref NET_OUT_GETCONNECTION_STATUS pOutParam, int nWaitTime);