当前位置: 首页>>代码示例>>C#>>正文


C# Management.ManagementBaseObject类代码示例

本文整理汇总了C#中System.Management.ManagementBaseObject的典型用法代码示例。如果您正苦于以下问题:C# ManagementBaseObject类的具体用法?C# ManagementBaseObject怎么用?C# ManagementBaseObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ManagementBaseObject类属于System.Management命名空间,在下文中一共展示了ManagementBaseObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NTLogEvent

 public NTLogEvent(System.Management.ManagementBaseObject theObject) {
     Initialize();
     embeddedObj = theObject;
     // PrivateSystemProperties = new ManagementSystemProperties(theObject);
     curObj = embeddedObj;
     isEmbedded = true;            
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:Win32_NTLogEvent.cs

示例2: ManagementException

		internal ManagementException(Exception e, string msg, ManagementBaseObject errObj) : base(msg, e)
		{
			try
			{
				if (e as ManagementException == null)
				{
					if (e as COMException == null)
					{
						this.errorCode = (ManagementStatus)base.HResult;
					}
					else
					{
						this.errorCode = (ManagementStatus)((COMException)e).ErrorCode;
					}
				}
				else
				{
					this.errorCode = ((ManagementException)e).ErrorCode;
					if (this.errorObject == null)
					{
						this.errorObject = null;
					}
					else
					{
						this.errorObject = (ManagementBaseObject)((ManagementException)e).errorObject.Clone();
					}
				}
			}
			catch
			{
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:32,代码来源:ManagementException.cs

示例3: OS

 public OS(ManagementBaseObject instance)
 {
     caption = (instance.Properties["Caption"].Value != null)
                      ? instance.Properties["Caption"].Value.ToString().Trim()
                      : string.Empty;
     version = (instance.Properties["Version"].Value != null)
                      ? instance.Properties["Version"].Value.ToString().Trim()
                      : string.Empty;
     buildNumber = (instance.Properties["BuildNumber"].Value != null)
                          ? instance.Properties["BuildNumber"].Value.ToString().Trim()
                          : string.Empty;
     buildType = (instance.Properties["BuildType"].Value != null)
                        ? instance.Properties["BuildType"].Value.ToString().Trim()
                        : string.Empty;
     bootDevice = (instance.Properties["BootDevice"].Value != null)
                         ? instance.Properties["BootDevice"].Value.ToString().Trim()
                         : string.Empty;
     systemDevice = (instance.Properties["SystemDevice"].Value != null)
                           ? instance.Properties["SystemDevice"].Value.ToString().Trim()
                           : string.Empty;
     windowsDirectory = (instance.Properties["WindowsDirectory"].Value != null)
                               ? instance.Properties["WindowsDirectory"].Value.ToString().Trim()
                               : string.Empty;
     systemDirectory = (instance.Properties["SystemDirectory"].Value != null)
                              ? instance.Properties["SystemDirectory"].Value.ToString().Trim()
                              : string.Empty;
     cSName = (instance.Properties["CSName"].Value != null)
                     ? instance.Properties["CSName"].Value.ToString().Trim()
                     : string.Empty;
     csdVersion = (instance.Properties["CsdVersion"].Value != null)
                         ? instance.Properties["CsdVersion"].Value.ToString().Trim()
                         : string.Empty;
     currentTimeZone = (instance.Properties["CurrentTimeZone"].Value != null)
                              ? instance.Properties["CurrentTimeZone"].Value.ToString().Trim()
                              : string.Empty;
     installDate = (instance.Properties["InstallDate"].Value != null)
                          ? instance.Properties["InstallDate"].Value.ToString().Trim()
                          : string.Empty;
     lastBootUpTime = (instance.Properties["LastBootUpTime"].Value != null)
                             ? instance.Properties["LastBootUpTime"].Value.ToString().Trim()
                             : string.Empty;
     organization = (instance.Properties["Organization"].Value != null)
                           ? instance.Properties["Organization"].Value.ToString().Trim()
                           : string.Empty;
     osLanguage = (instance.Properties["OsLanguage"].Value != null)
                         ? instance.Properties["OsLanguage"].Value.ToString().Trim()
                         : string.Empty;
     primary = (instance.Properties["Primary"].Value != null)
                      ? instance.Properties["Primary"].Value.ToString().Trim()
                      : string.Empty;
     registeredUser = (instance.Properties["RegisteredUser"].Value != null)
                             ? instance.Properties["RegisteredUser"].Value.ToString().Trim()
                             : string.Empty;
     serialNumber = (instance.Properties["SerialNumber"].Value != null)
                           ? instance.Properties["SerialNumber"].Value.ToString().Trim()
                           : string.Empty;
     totalVirtualMemorySize = (instance.Properties["TotalVirtualMemorySize"].Value != null)
                                     ? instance.Properties["TotalVirtualMemorySize"].Value.ToString().Trim()
                                     : string.Empty;
 }
开发者ID:hydrayu,项目名称:imobile-src,代码行数:60,代码来源:OS.cs

示例4: ObjectReadyEventArgs

	/// <summary>
	/// Constructor.
	/// </summary>
	/// <param name="context">The operation context which is echoed back
	/// from the operation which triggerred the event.</param>
	/// <param name="wmiObject">The newly arrived WmiObject.</param>
	internal ObjectReadyEventArgs (
					object context,
					ManagementBaseObject wmiObject
					) : base (context)
	{
		this.wmiObject = wmiObject;
	}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:13,代码来源:ManagementEventArgs.cs

示例5: GetImportedPvm

        GetImportedPvm(
            ManagementBaseObject outputParameters)
        {
            ManagementObject pvm = null;
            ManagementScope scope = new ManagementScope(@"root\virtualization\v2");

            if (WmiUtilities.ValidateOutput(outputParameters, scope))
            {
                if ((uint)outputParameters["ReturnValue"] == 0)
                {
                    pvm = new ManagementObject((string)outputParameters["ImportedSystem"]);
                }
                
                if ((uint)outputParameters["ReturnValue"] == 4096)
                {
                    using (ManagementObject job = 
                        new ManagementObject((string)outputParameters["Job"]))
                    using (ManagementObjectCollection pvmCollection = 
                        job.GetRelated("Msvm_PlannedComputerSystem",
                            "Msvm_AffectedJobElement", null, null, null, null, false, null))
                    {
                        pvm = WmiUtilities.GetFirstObjectFromCollection(pvmCollection);
                    }

                }
            }

            return pvm;
        }
开发者ID:dhanzhang,项目名称:Windows-classic-samples,代码行数:29,代码来源:ImportUtilities.cs

示例6: PropertyData

 internal PropertyData(ManagementBaseObject parent, string propName)
 {
     this.parent = parent;
     this.propertyName = propName;
     this.qualifiers = null;
     this.RefreshPropertyInfo();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:PropertyData.cs

示例7: FillDetails

        private static EntBios FillDetails(ManagementBaseObject obj)
        {
            EntBios objEntBios = new EntBios();
            try
            {
                objEntBios.ReleaseDate = WMIUtil.ToDateTime((string)obj["ReleaseDate"]);
            }
            catch (Exception)
            {
                objEntBios.ReleaseDate = DateTime.MinValue;
            }

            try
            {
                objEntBios.Manufacturer = WMIUtil.ToString(obj["Manufacturer"]);
            }
            catch (Exception)
            {
                objEntBios.Manufacturer = "";
            }

            try
            {
                objEntBios.Version = WMIUtil.ToString(obj["SMBIOSBIOSVersion"]);
            }
            catch (Exception)
            {
                objEntBios.Version = "";
            }

            return objEntBios;
        }
开发者ID:5dollartools,项目名称:NAM,代码行数:32,代码来源:Bios.cs

示例8: GetFromWmi

        public static VirtualMachineSnapshot GetFromWmi(ManagementBaseObject objSnapshot)
        {
            if (objSnapshot == null || objSnapshot.Properties.Count == 0)
                return null;

            VirtualMachineSnapshot snapshot = new VirtualMachineSnapshot();
            snapshot.Id = (string)objSnapshot["InstanceID"];
            snapshot.Name = (string)objSnapshot["ElementName"];

            string parentId = (string)objSnapshot["Parent"];
            if (!String.IsNullOrEmpty(parentId))
            {
                int idx = parentId.IndexOf("Microsoft:");
                snapshot.ParentId = parentId.Substring(idx, parentId.Length - idx - 1);
                snapshot.ParentId = snapshot.ParentId.ToLower().Replace("microsoft:", "");
            }
            if (!String.IsNullOrEmpty(snapshot.Id))
            {
                snapshot.Id = snapshot.Id.ToLower().Replace("microsoft:", "");
            }
            snapshot.Created = Wmi.ToDateTime((string)objSnapshot["CreationTime"]);

            if (string.IsNullOrEmpty(snapshot.ParentId))
                snapshot.ParentId = null; // for capability

            return snapshot;
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:27,代码来源:SnapshotHelper.cs

示例9: Add

 public virtual void Add(string methodName, ManagementBaseObject inParameters, ManagementBaseObject outParameters)
 {
     IWbemClassObjectFreeThreaded pInSignature = null;
     IWbemClassObjectFreeThreaded pOutSignature = null;
     if (this.parent.GetType() == typeof(ManagementObject))
     {
         throw new InvalidOperationException();
     }
     if (inParameters != null)
     {
         pInSignature = inParameters.wbemObject;
     }
     if (outParameters != null)
     {
         pOutSignature = outParameters.wbemObject;
     }
     int errorCode = -2147217407;
     try
     {
         errorCode = this.parent.wbemObject.PutMethod_(methodName, 0, pInSignature, pOutSignature);
     }
     catch (COMException exception)
     {
         ManagementException.ThrowWithExtendedInfo(exception);
     }
     if ((errorCode & 0xfffff000L) == 0x80041000L)
     {
         ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode);
     }
     else if ((errorCode & 0x80000000L) != 0L)
     {
         Marshal.ThrowExceptionForHR(errorCode);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:MethodDataCollection.cs

示例10: RetrieveProcessInfo

		static ProcessInfo RetrieveProcessInfo( ManagementBaseObject o )
		{
			return new ProcessInfo(
				Convert.ToInt32( o[ "ProcessId" ] ),
				(string)o[ "Name" ],
				(string)o[ "CommandLine" ] );
		}
开发者ID:amithasan,项目名称:Framework-Class-Library-Extension,代码行数:7,代码来源:ProcessTracker.cs

示例11: GetAddressHeaders

		static IEnumerable<AddressHeader> GetAddressHeaders (ManagementBaseObject obj, bool isLocal)
		{
			yield return CreateAddressHeader ("ClassName", CimNamespaces.CimNamespace, obj.ClassPath.ClassName);
			yield return CreateAddressHeader ("IsClass", CimNamespaces.CimNamespace, obj.ClassPath.IsClass);
			yield return CreateAddressHeader ("IsInstance", CimNamespaces.CimNamespace, obj.ClassPath.IsInstance);
			yield return CreateAddressHeader ("IsSingleton", CimNamespaces.CimNamespace, obj.ClassPath.IsSingleton);
			yield return CreateAddressHeader ("NamespacePath", CimNamespaces.CimNamespace, obj.ClassPath.NamespacePath);
			yield return CreateAddressHeader ("ServerName", CimNamespaces.CimNamespace, obj.ClassPath.Server);
			yield return CreateAddressHeader ("ObjectExits", CimNamespaces.CimNamespace, obj.ObjectExits);
			yield return CreateAddressHeader ("Qualifiers", CimNamespaces.CimNamespace, Serialize (obj.Qualifiers));
			yield return CreateAddressHeader ("Properties", CimNamespaces.CimNamespace, Serialize (obj.Properties, isLocal));
			yield return CreateAddressHeader ("SystemProperties", CimNamespaces.CimNamespace, SerializeSystem(obj.SystemProperties));

			ManagementObject o = obj as ManagementObject;
			if (o != null) {
				yield return CreateAddressHeader ("RelativePath", CimNamespaces.CimNamespace, o.Path.RelativePath);
				yield return CreateAddressHeader ("Path", CimNamespaces.CimNamespace, o.Path.Path);
			} else {
				yield return CreateAddressHeader ("Path", CimNamespaces.CimNamespace, obj.ClassPath.Path);
				yield return CreateAddressHeader ("RelativePath", CimNamespaces.CimNamespace, obj.ClassPath.RelativePath);
			}
			ManagementClass classObj = obj as ManagementClass;
			if (classObj != null) {
				yield return CreateAddressHeader ("CimClassName", CimNamespaces.CimNamespace, "Meta_Class");
				yield return CreateAddressHeader ("Methods", CimNamespaces.CimNamespace, Serialize (classObj.Methods, isLocal));
			}
			else {
				yield return CreateAddressHeader ("CimClassName", CimNamespaces.CimNamespace, obj.ClassPath.ClassName);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:30,代码来源:CimEnumerator.cs

示例12: FillDetails

        private static EntServices FillDetails(ManagementBaseObject obj)
        {
            EntServices objEntServices = new EntServices();
            try
            {
                objEntServices.DisplayName = WMIUtil.ToString(obj["DisplayName"]);
            }
            catch (Exception)
            {
                objEntServices.DisplayName = "";
            }

            try
            {
                objEntServices.Account = WMIUtil.ToString(obj["StartName"]);
            }
            catch (Exception)
            {
                objEntServices.Account = "";
            }

            try
            {
                objEntServices.Description = WMIUtil.ToString(obj["Description"]);
            }
            catch (Exception)
            {
                objEntServices.Description = "";
            }

            try
            {
                objEntServices.Path = WMIUtil.ToString(obj["PathName"]);
            }
            catch (Exception)
            {
                objEntServices.Path= "";
            }

            try
            {
                objEntServices.StartMode = WMIUtil.ToString(obj["StartMode"]);
            }
            catch (Exception)
            {
                objEntServices.StartMode = "";
            }

            try
            {
                objEntServices.State = WMIUtil.ToString(obj["State"]);
            }
            catch (Exception)
            {
                objEntServices.State = "";
            }

            return objEntServices;
        }
开发者ID:5dollartools,项目名称:NAM,代码行数:59,代码来源:Services.cs

示例13: CreateShare

        /// <summary>
        /// Creates the share.
        /// </summary>
        /// <param name="shareName">Name of the share.</param>
        /// <param name="folderPath">The folder path.</param>
        /// <returns>WindwsShare instance.</returns>
        public static WindowsShare CreateShare(string shareName, string folderPath)
        {
            ManagementClass shareClass = null;
            ManagementClass sd = null;
            ManagementBaseObject inParams = null;
            ManagementBaseObject outParams = null;

            try
            {
                sd = new ManagementClass(new ManagementPath("Win32_SecurityDescriptor"), null);

                sd["ControlFlags"] = 0x4;
                sd["DACL"] = new ManagementBaseObject[] { };

                shareClass = new ManagementClass("Win32_Share");

                inParams = shareClass.GetMethodParameters("Create");
                inParams["Name"] = shareName;
                inParams["Path"] = new DirectoryInfo(folderPath).FullName;
                //// inParams["Description"] = description;
                inParams["Type"] = 0x0;  // Type of Disk Drive
                inParams["Access"] = sd;

                outParams = shareClass.InvokeMethod("Create", inParams, null);

                if ((uint)outParams["ReturnValue"] != 0)
                {
                    throw new WindowsShareException("Unable to create share. Win32_Share.Create Error Code: " + outParams["ReturnValue"]);
                }
            }
            catch (Exception ex)
            {
                throw new WindowsShareException("Unable to create share", ex);
            }
            finally
            {
                if (shareClass != null)
                {
                    shareClass.Dispose();
                }

                if (inParams != null)
                {
                    inParams.Dispose();
                }

                if (outParams != null)
                {
                    outParams.Dispose();
                }

                if (sd != null)
                {
                    sd.Dispose();
                }
            }

            return new WindowsShare(shareName);
        }
开发者ID:mihaibuzgau,项目名称:cf-windows-extensions,代码行数:65,代码来源:WindowsShare.cs

示例14: FillDetails

        private static EntNetworkAdapter FillDetails(ManagementBaseObject obj)
        {
            EntNetworkAdapter objEntNetworkAdapter = new EntNetworkAdapter();
            try
            {
                objEntNetworkAdapter.AdapterMACAddress = WMIUtil.ToString(obj["MACAddress"]);
            }
            catch (Exception)
            {
                objEntNetworkAdapter.AdapterMACAddress = "";
            }

            try
            {
                objEntNetworkAdapter.AdapterType = WMIUtil.ToString(obj["AdapterType"]);
            }
            catch (Exception)
            {
                objEntNetworkAdapter.AdapterType = "";
            }

            try
            {
                objEntNetworkAdapter.Description = WMIUtil.ToString(obj["Description"]);
            }
            catch (Exception)
            {
                objEntNetworkAdapter.Description = "";
            }

            try
            {
                objEntNetworkAdapter.Manufacturer = WMIUtil.ToString(obj["Manufacturer"]);
            }
            catch (Exception)
            {
                objEntNetworkAdapter.Manufacturer = "";
            }

            try
            {
                objEntNetworkAdapter.Name = WMIUtil.ToString(obj["Name"]);
            }
            catch (Exception)
            {
                objEntNetworkAdapter.Name = "";
            }

            try
            {
                AvailabilityValues avaiType = (AvailabilityValues)WMIUtil.ToInteger(obj["Availability"]);
                objEntNetworkAdapter.Availability = avaiType.ToString();
            }
            catch (Exception)
            {
                objEntNetworkAdapter.Availability = "";
            }
            return objEntNetworkAdapter;
        }
开发者ID:5dollartools,项目名称:NAM,代码行数:59,代码来源:NetworkAdapter.cs

示例15: GetProperty

        private static string GetProperty(ManagementBaseObject obj, string property)
        {
            var value = (obj.GetPropertyValue(property) == null)
                            ? "NA"
                            : obj.GetPropertyValue(property).ToString();

            return value;
        }
开发者ID:FOGProject,项目名称:driver-pack-generator,代码行数:8,代码来源:DeviceFinder.cs


注:本文中的System.Management.ManagementBaseObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。