Exemplo n.º 1
0
        public uint Create(string Path, string Name, uint Type, uint MaximumAllowed,
                           string Description, string Password, Win32SecurityDescriptor Access)
        {
            ManagementObjectCollection moc = wmi.GetWSqlFromWMI("select * from Win32_Share  where Name='" + this.Name.ToString() + "'");
            ManagementObject           mop = null;

            foreach (ManagementObject mo in moc)
            {
                mop = mo;
            }
            ManagementBaseObject inbo = mop.GetMethodParameters("Create");

            inbo["Path"]           = Path;
            inbo["Name"]           = Name;
            inbo["Type"]           = Type;
            inbo["MaximumAllowed"] = MaximumAllowed;
            inbo["Description"]    = Description;
            inbo["Password"]       = Password;
            inbo["Access"]         = Access;

            ManagementBaseObject outbo = mop.InvokeMethod("Create", inbo, null);
            uint a = (uint)outbo["ReturnValue"];

            return(a);
        }
Exemplo n.º 2
0
        public uint Create(string CommandLine, string CurrentDirectory, Win32ProcessStartup ProcessStartupInformation, out uint ProcessId)
        {
            ManagementObjectCollection moc = wmi.GetWSqlFromWMI("select * from Win32_Process where Handle='" + this.Handle.ToString() + "'");
            ManagementObject           mop = null;

            foreach (ManagementObject mo in moc)
            {
                mop = mo;
            }
            ManagementBaseObject inbo = mop.GetMethodParameters("GetOwner");

            inbo["CommandLine"]               = CommandLine;
            inbo["CurrentDirectory"]          = CurrentDirectory;
            inbo["ProcessStartupInformation"] = ProcessStartupInformation;
            ManagementBaseObject outbo = mop.InvokeMethod("GetOwner", inbo, null);
            object c = outbo["ProcessId"];

            if (c != null)
            {
                ProcessId = (uint)c;
            }
            else
            {
                ProcessId = uint.MaxValue;
            }
            uint a = (uint)outbo["ReturnValue"];

            return(a);
        }
Exemplo n.º 3
0
        public override uint Reset()
        {
            if (this.wi == null)
            {
                throw new Exception("没有取得联接");
            }
            string Deviceid = this.DeviceID.ToString().Replace(@"\", @"\\");

            try
            {
                if (this.DeviceID == "" || this.DeviceID == null)
                {
                    throw new Exception("没有设置键值");
                }
                ManagementObjectCollection moc = wi.GetWSqlFromWMI("SELECT * FROM Win32_FloppyDrive where DeviceID='" + DeviceID + "'");
                uint a = 0;
                //				System.Console.WriteLine("SELECT * FROM Win32_FloppyDrive where DeviceID='"+Deviceid+"'");
                //测试Win2000时有错误,没有在任何类别中执行这个方法.估计是不支持win2000客户机的原因.
                foreach (ManagementObject mo in moc)
                {
                    a = (uint)mo.InvokeMethod("Reset", null);
                }
                return(a);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
        public uint Rename(string Name)
        {
            if (wmi != null)
            {
                ManagementObjectCollection moc = wmi.GetWSqlFromWMI("select * from Win32_Group where Name='" + Name + "'" + " and Domain='" + Domain + "'");

                uint a = 0;
                System.Console.WriteLine();
                foreach (ManagementObject mo in moc)
                {
                    a = (uint)mo.InvokeMethod("Rename", new object[] { Name });
                }

                return(a);
            }
            else
            {
                throw new Exception("Wmi没有联接,为null");
            }
        }
Exemplo n.º 5
0
        public override uint ChangeSecurityPermissions(Win32SecurityDescriptor SecurityDescriptor, uint Option)
        {
            ManagementObjectCollection moc = wmi.GetWSqlFromWMI("select * from Win32_Directory  where Name='" + this.Name.ToString().Replace(@"\", @"\\") + "'");
            ManagementObject           mop = null;
            uint a = 0;

            foreach (ManagementObject mo in moc)
            {
                mop = mo;
            }
            a = (uint)mop.InvokeMethod("ChangeSecurityPermissions", new object[] { SecurityDescriptor, Option });
            return(a);
        }
Exemplo n.º 6
0
 protected ManagementObjectCollection GetAllInfo(string wsql)
 {
     return(wi.GetWSqlFromWMI(wsql));
 }
Exemplo n.º 7
0
        public override uint Change(string DisplayName, string PathName, ushort ServiceType, byte ErrorControl, string StartMode, bool DesktopInteract,
                                    string StartName, string StartPassword, string LoadOrderGroup, string[] LoadOrderGroupDependencies, string[] ServiceDependencies)
        {
            byte b = 0;

            if (ServiceType != 256)
            {
                b = byte.Parse(ServiceType.ToString());
            }
            ManagementObjectCollection moc = wmi.GetWSqlFromWMI("select * from Win32_Service where Name='" + this.Name.ToString() + "'");
            ManagementObject           mop = null;

            foreach (ManagementObject mo in moc)
            {
                mop = mo;
            }
            ManagementBaseObject inbo = mop.GetMethodParameters("Change");

            inbo["DisplayName"]                = DisplayName;
            inbo["PathName"]                   = PathName;
            inbo["ServiceType"]                = b;
            inbo["ErrorControl"]               = ErrorControl;
            inbo["StartMode"]                  = StartMode;
            inbo["DesktopInteract"]            = DesktopInteract;
            inbo["StartName"]                  = StartName;
            inbo["StartPassword"]              = StartPassword;
            inbo["LoadOrderGroup"]             = LoadOrderGroup;
            inbo["LoadOrderGroupDependencies"] = LoadOrderGroupDependencies;
            inbo["ServiceDependencies"]        = ServiceDependencies;

            ManagementBaseObject outbo = mop.InvokeMethod("Change", inbo, null);
            uint a = (uint)outbo["ReturnValue"];

            return(a);
        }
Exemplo n.º 8
0
        public uint DisableIPSec()
        {
            ManagementObjectCollection moc = wmi.GetWSqlFromWMI("select * from Win32_NetworkAdapterConfiguration where Index=" + (uint)this.Index);

            uint a = uint.MaxValue;

            foreach (ManagementObject mo in moc)
            {
                a = (uint)mo.InvokeMethod("DisableIPSec", null);
            }

            return(a);
        }