Exemplo n.º 1
0
        private void CreateWmiDataProviderFromWmiItem(wmi_item wmiItem)
        {
            if (this.WmiDataProvider == null)
            {
                var wmiNamespace         = String.Format(@"{0}\{1}", this.TargetInfo.GetAddress(), [email protected]);
                var wmiNamespacePath     = new System.Management.ManagementPath(wmiNamespace);
                var wmiConnectionOptions = WmiDataProviderFactory.CreateConnectionOptions(this.TargetInfo);
                var wmiManagementScope   = new System.Management.ManagementScope(wmiNamespacePath, wmiConnectionOptions);
                wmiManagementScope.Connect();

                this.WmiDataProvider = new WmiDataProvider(wmiManagementScope);
            }
        }
Exemplo n.º 2
0
        private WmiDataProvider GetWmiDataProvider(string @namespace)
        {
            if (this.WmiDataProvider != null)
            {
                return(this.WmiDataProvider);
            }

            var wmiNamespace         = String.Format(@"\\{0}\{1}", this.TargetInfo.GetAddress(), @namespace);
            var wmiNamespacePath     = new System.Management.ManagementPath(wmiNamespace);
            var wmiConnectionOptions = WmiDataProviderFactory.CreateConnectionOptions(this.TargetInfo);
            var wmiManagementScope   = new System.Management.ManagementScope(wmiNamespacePath, wmiConnectionOptions);

            wmiManagementScope.Connect();

            return(new WmiDataProvider(wmiManagementScope));
        }
Exemplo n.º 3
0
        private void CreateWmiDataProviderFromWmiItem(wmi_item wmiItem)
        {
            if (this.WmiDataProvider == null)
            {
                var wmiNamespace = String.Format(@"{0}\{1}", this.TargetInfo.GetAddress(), [email protected]);
                var wmiNamespacePath = new System.Management.ManagementPath(wmiNamespace);
                var wmiConnectionOptions = WmiDataProviderFactory.CreateConnectionOptions(this.TargetInfo);
                var wmiManagementScope = new System.Management.ManagementScope(wmiNamespacePath, wmiConnectionOptions);
                wmiManagementScope.Connect();

                this.WmiDataProvider = new WmiDataProvider(wmiManagementScope);
            }
        }
Exemplo n.º 4
0
        private WmiDataProvider GetWmiDataProvider(string @namespace)
        {
            if (this.WmiDataProvider != null)
                return this.WmiDataProvider;

            var wmiNamespace = String.Format(@"\\{0}\{1}", this.TargetInfo.GetAddress(), @namespace);
            var wmiNamespacePath = new System.Management.ManagementPath(wmiNamespace);
            var wmiConnectionOptions = WmiDataProviderFactory.CreateConnectionOptions(this.TargetInfo);
            var wmiManagementScope = new System.Management.ManagementScope(wmiNamespacePath, wmiConnectionOptions);
            wmiManagementScope.Connect();

            return new WmiDataProvider(wmiManagementScope);
        }
 public static System.UInt32 ScheduleAutoChk(string[] LogicalDisk)
 {
     bool IsMethodStatic = true;
     if ((IsMethodStatic == true))
     {
         System.Management.ManagementBaseObject inParams = null;
         System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
         System.Management.ManagementClass classObj = new System.Management.ManagementClass(statMgmtScope, mgmtPath, null);
         inParams = classObj.GetMethodParameters("ScheduleAutoChk");
         inParams["LogicalDisk"] = LogicalDisk;
         System.Management.ManagementBaseObject outParams = classObj.InvokeMethod("ScheduleAutoChk", inParams, null);
         return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
     }
     else
     {
         return System.Convert.ToUInt32(0);
     }
 }
 public static LogicaldiskCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions)
 {
     if ((mgmtScope == null))
     {
         if ((statMgmtScope == null))
         {
             mgmtScope = new System.Management.ManagementScope();
             mgmtScope.Path.NamespacePath = "root\\cimv2";
         }
         else
         {
             mgmtScope = statMgmtScope;
         }
     }
     System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
     pathObj.ClassName = "Win32_Logicaldisk";
     pathObj.NamespacePath = "root\\cimv2";
     System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
     if ((enumOptions == null))
     {
         enumOptions = new System.Management.EnumerationOptions();
         enumOptions.EnsureLocatable = true;
     }
     return new LogicaldiskCollection(clsObject.GetInstances(enumOptions));
 }
 public static Logicaldisk CreateInstance()
 {
     System.Management.ManagementScope mgmtScope = null;
     if ((statMgmtScope == null))
     {
         mgmtScope = new System.Management.ManagementScope();
         mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
     }
     else
     {
         mgmtScope = statMgmtScope;
     }
     System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
     return new Logicaldisk(new System.Management.ManagementClass(mgmtScope, mgmtPath, null).CreateInstance());
 }