Exemplo n.º 1
0
 public CommPortInfo(CommPortInfo other) : this(msclPINVOKE.new_CommPortInfo__SWIG_1(CommPortInfo.getCPtr(other)), true)
 {
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 2
0
        public static List <CommPortInfo> EnumCommPorts()
        {
            List <CommPortInfo> commPorts = new List <CommPortInfo>();

            try
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PnPEntity WHERE ClassGuid='{4d36e978-e325-11ce-bfc1-08002be10318}'");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    CommPortInfo deviceObj = new CommPortInfo(queryObj);
                    if (deviceObj.PortName.StartsWith("LPT"))
                    {
                        continue;
                    }
                    Logger.Trace("Found a comm. port: " + deviceObj.PortName);
                    commPorts.Add(deviceObj);
                }
            }
            catch (Exception e)
            {
                Logger.Trace("Exception while listing the comm. ports");
                Logger.Trace(e.Message);
            }

            return(commPorts);
        }
Exemplo n.º 3
0
 public CommPortInfoEnumerator(CommPortInfo collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
Exemplo n.º 4
0
 public void SetRange(int index, CommPortInfo values)
 {
     msclPINVOKE.CommPortInfo_SetRange(swigCPtr, index, CommPortInfo.getCPtr(values));
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 5
0
        public CommPortInfo getCommPortInfo()
        {
            CommPortInfo ret = new CommPortInfo(msclPINVOKE.MipNodeFeatures_getCommPortInfo(swigCPtr), true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 6
0
        public static CommPortInfo Repeat(DeviceCommPort value, int count)
        {
            global::System.IntPtr cPtr = msclPINVOKE.CommPortInfo_Repeat(DeviceCommPort.getCPtr(value), count);
            CommPortInfo          ret  = (cPtr == global::System.IntPtr.Zero) ? null : new CommPortInfo(cPtr, true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 7
0
        public CommPortInfo GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = msclPINVOKE.CommPortInfo_GetRange(swigCPtr, index, count);
            CommPortInfo          ret  = (cPtr == global::System.IntPtr.Zero) ? null : new CommPortInfo(cPtr, true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 8
0
		public static List<CommPortInfo> EnumCommPorts()
		{
			List<CommPortInfo> commPorts = new List<CommPortInfo>();
			
			try
			{
				ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PnPEntity WHERE ClassGuid='{4d36e978-e325-11ce-bfc1-08002be10318}'");
				
				foreach (ManagementObject queryObj in searcher.Get())
				{
					CommPortInfo deviceObj = new CommPortInfo(queryObj);					
					if (deviceObj.PortName.StartsWith("LPT")) continue;					
					Logger.Trace("Found a comm. port: " + deviceObj.PortName);
					commPorts.Add(deviceObj);
				}
			}
			catch (Exception e)
			{
				Logger.Trace("Exception while listing the comm. ports");
				Logger.Trace(e.Message);
			}
			
			return commPorts;
		}
Exemplo n.º 9
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CommPortInfo obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }