Beispiel #1
0
 private void EnterLicense_Load(object sender, EventArgs e)
 {
     ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
     ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
     disk.Get();
     string temp = Des.EncryptDES(disk.GetPropertyValue("VolumeSerialNumber").ToString(), Des.ConstKey);
     tempStr = Des.EncryptDES(Des.EncryptDES(disk.GetPropertyValue("VolumeSerialNumber").ToString(), Des.ConstKey), Des.ConstKey);
     this.txtOnlyMsg.Text = temp.Trim();
     this.txtLicense.Text = DealXml.ReadSysConfig("appSettings", "license");
 }
        DisplayResourcePool(
            ManagementObject pool)
        {
            Console.WriteLine("Msvm_ResourcePool:");

            Console.WriteLine("\tPoolID: {0}", pool.GetPropertyValue("PoolID"));
            Console.WriteLine("\tInstanceID: {0}", pool.GetPropertyValue("InstanceID"));
            Console.WriteLine("\tResourceType: {0}", pool.GetPropertyValue("ResourceType"));
            Console.WriteLine("\tResourceSubtype: {0}", pool.GetPropertyValue("ResourceSubType"));
        }
Beispiel #3
0
 //获取硬盘卷标号
 public static string GetDiskVolumeSerialNumber()
 {
     ManagementClass mc = new ManagementClass("win32_NetworkAdapterConfiguration");
     ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
     disk.Get();
     return disk.GetPropertyValue("VolumeSerialNumber").ToString();
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of TaskManager.CService class to the value of System.ServiceProcess.ServiceController object.
 /// </summary>
 /// <param name="Srvc">Object of System.ServiceProcess.ServiceController to initialize TaskManager.CService object.</param>
 public CService(ServiceController Srvc)
 {
     Name = Srvc.ServiceName;
     Description = Srvc.DisplayName;
     Status = Srvc.Status;
     ManagementObject MO = new ManagementObject(@"Win32_service.Name='" + Srvc.ServiceName + "'");
     Id = Int32.Parse(MO.GetPropertyValue("ProcessID").ToString());
 }
        /// <summary>
        /// 取得设备硬盘的卷标号
        /// </summary>
        /// <returns></returns>
        private string GetDiskVolumeSerialNumber() {
            try {
                ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
                ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
                disk.Get();
                return disk.GetPropertyValue("VolumeSerialNumber").ToString();
            } catch {
                return "unknow";
            } finally {

            }
        }
Beispiel #6
0
 public string GetVolumeID()
 {
     ManagementObject managementObject = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
     string result;
     try
     {
         managementObject.Get();
         result = managementObject.GetPropertyValue("VolumeSerialNumber").ToString();
         return result;
     }
     catch
     {
     }
     result = "ABC";
     return result;
 }
 static string ServiceStartupType(string ServiceName)
 {
     string objPath = string.Format("Win32_Service.Name='{0}'", ServiceName);
      using (ManagementObject service = new ManagementObject(new ManagementPath(objPath)))
      {
          try
          {
             return (string)service.GetPropertyValue("StartMode");
          }
          catch
          {
              return string.Empty;
          }
      }
 }
 public static Win32_OperatingSystem MapToWin32_OperatingSystem(this ManagementObject mos) => new Win32_OperatingSystem
 {
     BootDevice          = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.BootDevice)),
     BuildNumber         = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.BuildNumber)),
     BuildType           = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.BuildType)),
     Caption             = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.Caption)),
     CodeSet             = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.CodeSet)),
     CountryCode         = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.CountryCode)),
     CreationClassName   = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.CreationClassName)),
     CSCreationClassName = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.CSCreationClassName)),
     CSDVersion          = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.CSDVersion)),
     CSName          = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.CSName)),
     CurrentTimeZone = mos.GetPropertyValue <short>(nameof(Win32_OperatingSystem.CurrentTimeZone)),
     DataExecutionPrevention_Available         = mos.GetPropertyValue <bool>(nameof(Win32_OperatingSystem.DataExecutionPrevention_Available)),
     DataExecutionPrevention_32BitApplications = mos.GetPropertyValue <bool>(nameof(Win32_OperatingSystem.DataExecutionPrevention_32BitApplications)),
     DataExecutionPrevention_Drivers           = mos.GetPropertyValue <bool>(nameof(Win32_OperatingSystem.DataExecutionPrevention_Drivers)),
     DataExecutionPrevention_SupportPolicy     = mos.GetPropertyValue <byte>(nameof(Win32_OperatingSystem.DataExecutionPrevention_SupportPolicy)),
     Debug                      = mos.GetPropertyValue <bool>(nameof(Win32_OperatingSystem.Debug)),
     Description                = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.Description)),
     Distributed                = mos.GetPropertyValue <bool>(nameof(Win32_OperatingSystem.Distributed)),
     EncryptionLevel            = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.EncryptionLevel)),
     ForegroundApplicationBoost = mos.GetPropertyValue <byte>(nameof(Win32_OperatingSystem.ForegroundApplicationBoost)),
     FreePhysicalMemory         = mos.GetPropertyValue <ulong>(nameof(Win32_OperatingSystem.FreePhysicalMemory)),
     FreeSpaceInPagingFiles     = mos.GetPropertyValue <ulong>(nameof(Win32_OperatingSystem.FreeSpaceInPagingFiles)),
     FreeVirtualMemory          = mos.GetPropertyValue <ulong>(nameof(Win32_OperatingSystem.FreeVirtualMemory)),
     InstallDate                = mos.GetPropertyValue <DateTime>(nameof(Win32_OperatingSystem.InstallDate)),
     LargeSystemCache           = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.LargeSystemCache)),
     LastBootUpTime             = mos.GetPropertyValue <DateTime>(nameof(Win32_OperatingSystem.LastBootUpTime)),
     LocalDateTime              = mos.GetPropertyValue <DateTime>(nameof(Win32_OperatingSystem.LocalDateTime)),
     Locale                     = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.Locale)),
     Manufacturer               = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.Manufacturer)),
     MaxNumberOfProcesses       = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.MaxNumberOfProcesses)),
     MaxProcessMemorySize       = mos.GetPropertyValue <ulong>(nameof(Win32_OperatingSystem.MaxProcessMemorySize)),
     MUILanguages               = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.MUILanguages)),
     Name = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.Name)),
     NumberOfLicensedUsers = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.NumberOfLicensedUsers)),
     NumberOfProcesses     = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.NumberOfProcesses)),
     NumberOfUsers         = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.NumberOfUsers)),
     OperatingSystemSKU    = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.OperatingSystemSKU)),
     Organization          = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.Organization)),
     OSArchitecture        = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.OSArchitecture)),
     OSLanguage            = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.OSLanguage)),
     OSProductSuite        = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.OSProductSuite)),
     OSType = mos.GetPropertyValue <ushort>(nameof(Win32_OperatingSystem.OSType)),
     OtherTypeDescription    = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.OtherTypeDescription)),
     PAEEnabled              = mos.GetPropertyValue <bool>(nameof(Win32_OperatingSystem.PAEEnabled)),
     PlusProductID           = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.PlusProductID)),
     PlusVersionNumber       = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.PlusVersionNumber)),
     PortableOperatingSystem = mos.GetPropertyValue <bool>(nameof(Win32_OperatingSystem.PortableOperatingSystem)),
     Primary                 = mos.GetPropertyValue <bool>(nameof(Win32_OperatingSystem.Primary)),
     ProductType             = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.ProductType)),
     RegisteredUser          = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.RegisteredUser)),
     SerialNumber            = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.SerialNumber)),
     ServicePackMajorVersion = mos.GetPropertyValue <ushort>(nameof(Win32_OperatingSystem.ServicePackMajorVersion)),
     ServicePackMinorVersion = mos.GetPropertyValue <ushort>(nameof(Win32_OperatingSystem.ServicePackMinorVersion)),
     SizeStoredInPagingFiles = mos.GetPropertyValue <ulong>(nameof(Win32_OperatingSystem.SizeStoredInPagingFiles)),
     Status                 = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.Status)),
     SuiteMask              = mos.GetPropertyValue <uint>(nameof(Win32_OperatingSystem.SuiteMask)),
     SystemDevice           = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.SystemDevice)),
     SystemDirectory        = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.SystemDirectory)),
     SystemDrive            = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.SystemDrive)),
     TotalSwapSpaceSize     = mos.GetPropertyValue <ulong>(nameof(Win32_OperatingSystem.TotalSwapSpaceSize)),
     TotalVirtualMemorySize = mos.GetPropertyValue <ulong>(nameof(Win32_OperatingSystem.TotalVirtualMemorySize)),
     TotalVisibleMemorySize = mos.GetPropertyValue <ulong>(nameof(Win32_OperatingSystem.TotalVisibleMemorySize)),
     Version                = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.Version)),
     WindowsDirectory       = mos.GetPropertyValue <string>(nameof(Win32_OperatingSystem.WindowsDirectory)),
     QuantumLength          = mos.GetPropertyValue <byte>(nameof(Win32_OperatingSystem.QuantumLength)),
     QuantumType            = mos.GetPropertyValue <byte>(nameof(Win32_OperatingSystem.QuantumType))
 };
        PrintReplicationRelationshipObject(
            ManagementObject relationshipObject)
        {
            DateTime lastReplicationTime = ManagementDateTimeConverter.ToDateTime(
                relationshipObject.GetPropertyValue("LastReplicationTime").ToString());
            DateTime lastApplyTime = ManagementDateTimeConverter.ToDateTime(
                relationshipObject.GetPropertyValue("LastApplyTime").ToString());
            ReplicationHealth replicationHealth = 
                (ReplicationHealth)((UInt16)relationshipObject.GetPropertyValue("ReplicationHealth"));
            ReplicationState replicationState = 
                (ReplicationState)((UInt16)relationshipObject.GetPropertyValue("ReplicationState"));
            bool isPrimaryRelationship = 
                relationshipObject.GetPropertyValue("InstanceID").ToString().EndsWith("0", StringComparison.CurrentCulture);

            Console.WriteLine("Name               \t: {0}", 
                relationshipObject.GetPropertyValue("ElementName").ToString());
            Console.WriteLine("RelationshipType   \t: {0}", 
                isPrimaryRelationship ? "Primary" : "Extended");
            Console.WriteLine("ReplicationHealth  \t: {0}", replicationHealth.ToString());
            Console.WriteLine("ReplicationState   \t: {0}", replicationState.ToString());
            Console.WriteLine("LastReplicationTime\t: {0}", lastReplicationTime.ToString());
            Console.WriteLine("LastApplyTime      \t: {0}", lastApplyTime.ToString());
        }
 public void setMetric(ManagementObject adapter, int metric)
 {
     try
     {
         ManagementBaseObject setGateway;
         ManagementBaseObject newGateway = adapter.GetMethodParameters("SetGateways");
         newGateway["DefaultIPGateway"] = new string[] { adapter.GetPropertyValue("DefaultIPGateway").ToString() };
         newGateway["GatewayCostMetric"] = new int[] { metric };
         setGateway = adapter.InvokeMethod("SetGateways", newGateway,  null);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #11
0
        private WmiObject createWmiObjectsFromSingleObject(ManagementObject managementObject)
        {
            WmiObject wmiObject = new WmiObject();
            foreach (PropertyData property in managementObject.Properties)
                wmiObject.Add(property.Name, managementObject.GetPropertyValue(property.Name));

            return wmiObject;
        }
 private static bool IsThisExecutable(ManagementObject mo)
 {
     var path = mo.GetPropertyValue("PathName").ToString();
     return path.Contains(Assembly.GetEntryAssembly().Location);
 }
Beispiel #13
0
 private static LinkSAP80211 Instantiate80211(ManagementObject linkSap80211MO, ushort fromMIHFPort, System.Net.IPAddress mihAddr)
 {
     return new LinkSAP80211((string)linkSap80211MO.GetPropertyValue("GUID"), fromMIHFPort, mihAddr);
 }
 public SoundDevice(ManagementObject soundDevice)
 {
     deviceID = soundDevice.GetPropertyValue("DeviceID").ToString();
     name = soundDevice.GetPropertyValue("Name").ToString();
 }
 DisplayPoolResourcePoolSettingData(
     ManagementScope scope,
     ManagementObject pool)
 {
     using (ManagementObject rpsd =
         MsvmResourcePoolSettingData.GetPoolResourcePoolSettingData(
             scope,
             pool.GetPropertyValue("ResourceType").ToString(),
             pool.GetPropertyValue("ResourceSubType").ToString(),
             pool.GetPropertyValue("PoolId").ToString()))
     {
         Console.WriteLine("Msvm_ResourcePoolSettingData:");
         Console.WriteLine("\tPoolId: {0}", rpsd.GetPropertyValue("PoolId"));
         Console.WriteLine("\tElementName: {0}", rpsd.GetPropertyValue("ElementName"));
         Console.WriteLine("\tInstanceID: {0}", rpsd.GetPropertyValue("InstanceID"));
         Console.WriteLine("\tResourceType: {0}", rpsd.GetPropertyValue("ResourceType"));
         Console.WriteLine("\tResourceSubType: {0}", rpsd.GetPropertyValue("ResourceSubType"));
     }
 }
Beispiel #16
0
        /// <summary>
        /// ȡӲ�����к�
        /// </summary>
        /// <returns></returns>
        private string getVolumnSerial()
        {
            string serial;
            try
            {
                System.Management.ManagementObject disk = new System.Management.ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
                disk.Get();
                //ȡ�������
                System.Net.IPHostEntry myHost = new System.Net.IPHostEntry();
                myHost = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName());
                string computername  = myHost.HostName.ToString().Trim();
                computername = "";

                serial=disk.GetPropertyValue("VolumeSerialNumber").ToString();
                return serial;
            }
            catch
            {
                return "24F779C7";
            }
        }
Beispiel #17
0
 private string GetOSServicePack(string servicePack, ManagementObject managementObject)
 {
     int servicePackNumber = Convert.ToInt32(managementObject.GetPropertyValue("ServicePackMajorVersion"));
     if (servicePackNumber != 0)
     {
         servicePack = $"Service Pack {servicePackNumber}";
     }
     return servicePack;
 }
 private static Service Map(ManagementObject mo)
 {
     return new Service
         {
             ServiceName = mo.GetPropertyValue("Name").ToString(),
             DisplayName = mo.GetPropertyValue("DisplayName").ToString(),
             DescriptionWithCommandLine = mo.GetPropertyValue("Description").ToString(),
             ProcessId = int.Parse(mo.GetPropertyValue("ProcessID").ToString())
         };
 }
 static string ServiceStartupType(string ServiceName)
 {
     string objPath = string.Format("Win32_Service.Name='{0}'", ServiceName);
      using (ManagementObject service = new ManagementObject(new ManagementPath(objPath)))
      {
          try
          {
              string value = (string)service.GetPropertyValue("StartMode");
              return value;  // Auto, Manual or Disabled  (note Auto not Automatic)
          }
          catch
          {
              return string.Empty;
          }
      }
 }
Beispiel #20
0
 public string GetDiskInfo()
 {
     ManagementClass class2 = new ManagementClass("Win32_NetworkAdapterConfiguration");
     ManagementObject obj2 = new ManagementObject("Win32_logicaldisk.deviceid=\"c:\"");
     obj2.Get();
     return obj2.GetPropertyValue("VolumeSerialNumber").ToString();
 }
Beispiel #21
0
			private void CountQueueMessages(QSetQueueItem queueItem)
			{				
				//first of all, ensure we have a node to work with
				QueueItemListViewItemPair itemPair = null;
				if (_itemPairHashTable.ContainsKey(queueItem.ID))
					itemPair = (QSetMonitorWorker.QueueItemListViewItemPair)_itemPairHashTable[queueItem.ID];
				else
				{
					//TODO create icon
					itemPair = new QueueItemListViewItemPair(queueItem, new ListViewItem(queueItem.Name, (int)Images.IconType.Queue));					
					for (int subItemCounter = 0; subItemCounter < _COLUMNS; subItemCounter ++)
						itemPair.ListViewItem.SubItems.Add(string.Empty);
					_itemPairHashTable.Add(itemPair.QSetQueueItem.ID, itemPair);
					
                    Action x = delegate { _monitorListView.Items.Add(itemPair.ListViewItem); };
                    _monitorListView.Invoke(x);
				}
				
				ManagementObject counter = null;
				try
				{										
					counter = new ManagementObject(String.Format("Win32_PerfRawdata_MSMQ_MSMQQueue.name='{0}'", itemPair.QSetQueueItem.Name));
					counter.Get();			
					uint outgoingMessageCount = Convert.ToUInt32(counter.GetPropertyValue("MessagesInQueue"));
                    uint outgoingBytes = Convert.ToUInt32(counter.GetPropertyValue("BytesInQueue"));

                    Action herewegoagain = () =>
                        {
                            if (itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingMessageCount].Text != outgoingMessageCount.ToString()) //note: only do if necessary, to avoid flicker
                                itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingMessageCount].Text = outgoingMessageCount.ToString();

                            if (itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingBytes].Text != outgoingBytes.ToString()) //note: only do if necessary, to avoid flicker
                                itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingBytes].Text = outgoingBytes.ToString();
                        };


                    _monitorListView.Invoke(herewegoagain);
				}
				catch
				{
					//exception will occur when cannot get access to performance counters
				}
				finally
				{
					if (counter != null)
						counter.Dispose();
				}
			}
Beispiel #22
0
 private static void KillService(string serviceName)
 {
     using (ManagementObject service = new ManagementObject(@"Win32_service.Name='" + serviceName + "'"))
     {
         object o = service.GetPropertyValue("ProcessId");
         int processId = (int)((UInt32)o);
         using (Process process = Process.GetProcessById(processId))
         {
             process.Kill();
         }
     }
 }
 public void Update(ManagementObject proc)
 {
     this.PreviousProcTime = this.CurrentProcTime;
     this.PreviousTimeStamp = this.CurrentTimeStamp;
     this.Name = Convert.ToString(proc.GetPropertyValue(PROC_NAME));
     this.CurrentProcTime = Convert.ToInt64(proc.GetPropertyValue(PROC_TIME));
     this.CurrentTimeStamp = Convert.ToInt64(proc.GetPropertyValue(TIME_STAMP));
     this.CurrentMemory = Convert.ToInt64(proc.GetPropertyValue(WorkingSet()));
     this.ProcessId = Convert.ToInt32(proc.GetPropertyValue(PROC_ID));
     this.CalculateProcPercent();
 }
        DisplayPoolResourceAllocationSettingData(
            ManagementObject rasd)
        {
            Console.WriteLine("Msvm_ResourceAllocationSettingData:");

            if (rasd == null)
            {
                Console.WriteLine("\tA primordial pool does not have an associated " +
                    "Msvm_ResourceAllocationSettingData object.");

                return;
            }

            Console.WriteLine("\tElementName: {0}", rasd.GetPropertyValue("ElementName"));
            Console.WriteLine("\tCaption: {0}", rasd.GetPropertyValue("Caption"));
            Console.WriteLine("\tInstanceID: {0}", rasd.GetPropertyValue("InstanceID"));
            Console.WriteLine("\tResourceType: {0}", rasd.GetPropertyValue("ResourceType"));
            Console.WriteLine("\tResourceSubType: {0}", rasd.GetPropertyValue("ResourceSubType"));

            string[] hostResources = (string[])rasd.GetPropertyValue("HostResource");

            if (hostResources != null)
            {
                Console.WriteLine("\tHostResources:");

                foreach (string resource in hostResources)
                {
                    Console.WriteLine("\t\t" + resource);
                }
            }
        }
 DisplayPoolResourceAllocationSettingData(
     ManagementScope scope,
     ManagementObject pool)
 {
     using (ManagementObject rasd =
         MsvmResourceAllocationSettingData.GetAllocationSettingsForPool(
             scope,
             pool.GetPropertyValue("ResourceType").ToString(),
             pool.GetPropertyValue("ResourceSubType").ToString(),
             pool.GetPropertyValue("PoolId").ToString()))
     {
         DisplayPoolResourceAllocationSettingData(rasd);
     }
 }
Beispiel #26
0
			public DeviceInfo(ManagementObject device)
			{
				this.device = device;

				_HardwareID = null;
				
				if (_HardwareID == null)
				{
					try
					{
						string[] s = (string[]) device.GetPropertyValue("HardwareID");
						_HardwareID = s[0];
					}
					catch
					{
	
					}
				}
				if (_HardwareID == null)
				{
					try
					{
						_HardwareID = (string) device.GetPropertyValue("HardwareID");
					}
					catch
					{
							
					}
				}
				
				if (_HardwareID == null)
				{
					_HardwareID = device.Path.Path;
					_HardwareID = _HardwareID.Replace("\\\\", "\\");					
					string C = "DeviceID=";
					if (_HardwareID.Contains(C))
					{
						_HardwareID = _HardwareID.Substring(_HardwareID.IndexOf(C) + C.Length);
						if (_HardwareID.StartsWith("\"") && _HardwareID.EndsWith("\"") && (_HardwareID.Length >= 2))
							_HardwareID = _HardwareID.Substring(1, _HardwareID.Length - 2);
					}					
				}
				
				_FriendlyName = (string) device.GetPropertyValue("Caption");
				
				_Type = "";
				
				if (this.wVendorID == SpringCard_VendorIDw)
				{
					switch (this.wProductID)
					{
						case 0x7241 :
							_FriendlyName = "SpringCard RFID Scanner";
							break;
						case 0x9241 :
							_FriendlyName = "SpringCard RFID Scanner HSP";
							break;
						default :
							break;
					}
					switch (this.wProductID & 0x0F00)
					{
						case 0x0000 :
							_Type = "VCP";
							break;
						case 0x0100 :
							_Type = "PC/SC";
							break;
						case 0x0200 :
							_Type = "RFID Scanner";					
							break;								
						default :
							break;
					}
				}
				else if ((this.wVendorID == 0x03EB) && (this.wProductID == 0x2FF6))
				{
					_Type = "Atmel DFU";
				}
			}
Beispiel #27
0
 /// <summary>
 /// 获得硬盘ID
 /// </summary>
 /// <returns></returns>
 public static string GetDiskVolumeSerialNumber()
 {
     try
     {
         ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
         ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"d:\"");
         disk.Get();
         return disk.GetPropertyValue("VolumeSerialNumber").ToString();
     }
     catch (System.Exception ex)
     {
         return null;
     }
 }
Beispiel #28
0
 /// <summary>
 /// 获取硬盘序列号
 /// </summary>
 /// <returns></returns>
 private string GetHDSerialNo()
 {
     try
     {
         ManagementObject obj2 = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
         obj2.Get();
         return obj2.GetPropertyValue("VolumeSerialNumber").ToString();
     }
     catch
     {
         return "FFFF";
     }
 }
    private void onEventArrived(object sender, EventArrivedEventArgs e)
    {
      ManagementBaseObject _o = e.NewEvent["TargetInstance"] as ManagementBaseObject;
      if (_o == null) return;

      ManagementObject mo = new ManagementObject(_o["Dependent"].ToString());
      if (mo == null) return;

      IList<DeviceInstance> newDeviceList = new DirectInput().GetDevices(DeviceClass.GameController,
                                                                         DeviceEnumerationFlags.AttachedOnly);
      if (_deviceList != null && _deviceList.Count == newDeviceList.Count) return;

      try
      {
        if (mo.GetPropertyValue("DeviceID").ToString() != string.Empty)
        {
          //connected
          IrssLog.Debug("DirectInput: An USB device has been connected");
          RestartListener();
        }
      }
      catch
      {
        //disconnected
        IrssLog.Debug("DirectInput: An USB device has been disconnected");
        if (newDeviceList.Count == 0)
          StopListener();
        else
          RestartListener();
      }
    }
            /// <summary>
            /// Изменяет имя рабочей группы, только если не является чатью домена
            /// </summary>
            /// <param name="workgroup"></param>
            /// <returns></returns>
            public bool SetWorkgroup(string workgroup)
            {
                bool complete = false;
                try
                {
                    ManagementObject objMO = new ManagementObject(string.Format("Win32_ComputerSystem.Name='{0}'",
                    Environment.MachineName));
                    if (!(bool)objMO.GetPropertyValue("PartOfDomain"))
                    {
                        ManagementBaseObject wGroup = objMO.GetMethodParameters("JoinDomainOrWorkgroup");
                        wGroup.SetPropertyValue("Name", workgroup);

                        ManagementBaseObject setwGroup = objMO.InvokeMethod("JoinDomainOrWorkgroup", wGroup, null);
                        complete = true;
                        return complete;
                    }

                }
                catch (Exception) { throw; }
                return complete;
            }
Beispiel #31
-1
 private void UpdateFromWmi(ManagementObject wmiObject)
 {
     this.WmiPath = (string)wmiObject.GetPropertyValue("__PATH");
     this.Index = (UInt32)wmiObject.GetPropertyValue("Index");
     this.Guid = Guid.Parse((string)wmiObject.GetPropertyValue("GUID"));
     this.MACAddress = (string)wmiObject.GetPropertyValue("MACAddress");
     this.Name = (string)wmiObject.GetPropertyValue("Name");
     this.NetConnectionID = (string)wmiObject.GetPropertyValue("NetConnectionID");
     this.Speed = (UInt64)wmiObject.GetPropertyValue("Speed");
     var connectionStatus = ConnectionStatus;
     this.IsWireless = true;
     try
     {
         var wirelessConnectionStatus = WirelessConnectionStatus;
     }
     catch (Exception) {
         this.IsWireless = false;
     };
 }