private void getJavaServerID()
        {
            string query = "SELECT ProcessId FROM Win32_Process WHERE Name = 'java.exe' AND CommandLine LIKE '%StarMade%'";

            List<Process> servers = null;
            using (var results = new ManagementObjectSearcher(query).Get())
                servers = results.Cast<ManagementObject>()
                                 .Select(mo => Process.GetProcessById((int)(uint)mo["ProcessId"]))
                                 .ToList();
            processID = servers[0].Id;
        }
        public static void Stop()
        {
            const string query = "SELECT ProcessId "
                                 + "FROM Win32_Process "
                                 + "WHERE Name = 'java.exe' "
                                 + "AND CommandLine LIKE '%fuseki-server.jar%'";

            List<Process> servers = null;
            using (var results = new ManagementObjectSearcher(query).Get())
                servers = results.Cast<ManagementObject>()
                                 .Select(mo => Process.GetProcessById((int)(uint)mo["ProcessId"]))
                                 .ToList();

            foreach (var process in servers)
            {
                process.Kill();
            }
        }
        private static MyProcessStartAnalytics GetProcessStartAnalyticsData()
        {
            MyProcessStartAnalytics data = new MyProcessStartAnalytics();
            var cpus = new ManagementObjectSearcher("root\\CIMV2", "SELECT Name FROM Win32_Processor").Get();
            // We're just reporting the first 
            var cpuName = cpus.Cast<ManagementObject>().First()["Name"].ToString();

            var memoryInfo = new WinApi.MEMORYSTATUSEX();
            WinApi.GlobalMemoryStatusEx(memoryInfo);

            var deviceName =
                MyVideoSettingsManager.Adapters[MyVideoSettingsManager.CurrentDeviceSettings.AdapterOrdinal]
                    .Name;

            data.OsVersion = Environment.OSVersion.VersionString;
            data.CpuInfo = cpuName;
            data.GpuInfo = deviceName;
            data.GameVersion = MyFinalBuildConstants.APP_VERSION_STRING.ToString();
            data.TotalPhysMemBytes = memoryInfo.ullTotalPhys;

            return data;
        }
        /// <summary>
        /// The get ip addresses.
        /// </summary>
        /// <returns>
        /// </returns>
        private List<string> GetIpAddresses()
        {
            var ips = new List<string>();

            string query = "SELECT IPAddress from Win32_NetworkAdapterConfiguration WHERE IPEnabled=true";
            ManagementObjectCollection mgtObjects = new ManagementObjectSearcher(query).Get();

            foreach (
                PropertyData ipaddr in
                    mgtObjects.Cast<ManagementObject>().Select(mo => mo.Properties["IPAddress"]).Where(ipaddr => ipaddr.IsLocal))
            {
                if (ipaddr.IsArray)
                {
                    ips.AddRange((string[])ipaddr.Value);
                }
                else
                {
                    ips.Add(ipaddr.Value.ToString());
                }
            }

            return ips;
        }
		private void CollectMotherboard(bool usecache)
		{
			if (usecache && _isMotherboardCollected)
				return;

			try
			{
				var moc = new ManagementObjectSearcher("SELECT * FROM Win32_MotherboardDevice").Get();
				foreach (var o in moc.Cast<ManagementObject>())
				{
					PrimaryBusType = o.TryGet<string>("PrimaryBusType");
					SecondaryBusType = o.TryGet<string>("SecondaryBusType");
					break;
				}
			}
			catch (Exception)
			{
			}


			_isMotherboardCollected = true;
		}
        private static MyProcessStartAnalytics GetProcessStartAnalyticsData()
        {
            MyProcessStartAnalytics data = new MyProcessStartAnalytics();
            try
            {
                var cpus = new ManagementObjectSearcher("root\\CIMV2", "SELECT Name FROM Win32_Processor").Get();
                // We're just reporting the first 
                var cpuName = cpus.Cast<ManagementObject>().First()["Name"].ToString();

                var memoryInfo = new WinApi.MEMORYSTATUSEX();
                WinApi.GlobalMemoryStatusEx(memoryInfo);

                MyAdapterInfo gpu = MyVideoSettingsManager.Adapters[MyVideoSettingsManager.CurrentDeviceSettings.AdapterOrdinal];
                var deviceName = gpu.Name;
                
                data.ProcessorCount = (byte)Environment.ProcessorCount;
                data.OsVersion = Environment.OSVersion.VersionString;
                data.CpuInfo = cpuName;
                data.OsPlatform = Environment.Is64BitOperatingSystem ? "64bit" : "32bit";
                data.HasDX11 = MyDirectXHelper.IsDx11Supported();
                data.GameVersion = MyFinalBuildConstants.APP_VERSION_STRING.ToString();
                data.TotalPhysMemBytes = memoryInfo.ullTotalPhys;
                data.GpuInfo = new MyGraphicsInfo();
                data.GpuInfo.AnisotropicFiltering = MyVideoSettingsManager.CurrentGraphicsSettings.Render.AnisotropicFiltering.ToString();
                data.GpuInfo.AntialiasingMode = MyVideoSettingsManager.CurrentGraphicsSettings.Render.AntialiasingMode.ToString();
                data.GpuInfo.FoliageDetails = MyVideoSettingsManager.CurrentGraphicsSettings.Render.FoliageDetails.ToString();
                data.GpuInfo.ShadowQuality = MyVideoSettingsManager.CurrentGraphicsSettings.Render.ShadowQuality.ToString();
                data.GpuInfo.TextureQuality = MyVideoSettingsManager.CurrentGraphicsSettings.Render.TextureQuality.ToString();
                data.GpuInfo.VoxelQuality = MyVideoSettingsManager.CurrentGraphicsSettings.Render.VoxelQuality.ToString();
                data.GpuInfo.GrassDensityFactor = MyVideoSettingsManager.CurrentGraphicsSettings.Render.GrassDensityFactor;
                data.GpuInfo.GPUModelName = gpu.DeviceName;
                data.GpuInfo.GPUMemory = gpu.VRAM;
                data.AudioInfo.MusicVolume = MySandboxGame.Config.MusicVolume;
                data.AudioInfo.SoundVolume = MySandboxGame.Config.GameVolume;
                data.AudioInfo.HudWarnings = MySandboxGame.Config.HudWarnings;
                data.AudioInfo.MuteWhenNotInFocus = MySandboxGame.Config.EnableMuteWhenNotInFocus;
                data.Fullscreen = MyVideoSettingsManager.CurrentDeviceSettings.WindowMode.ToString();
                data.Resolution = MySandboxGame.Config.ScreenWidth.ToString() + " x " + MySandboxGame.Config.ScreenHeight.ToString();
            }
            catch (Exception exception)
            {
                MyLog.Default.WriteLine(exception);
            }

            return data;
        }
Beispiel #7
0
 public static bool PathIsFromVHD(string Location)
 {
     string root = Path.GetPathRoot(Location);
     if (root == null)
         return false;
     var scope = new ManagementScope(@"root\cimv2");
     scope.Connect();
     var drives = new ManagementObjectSearcher(scope,
                                  new SelectQuery(DiskStrings.LogicalDisk,
                                                  "DeviceID like '" +
                                                  root.Substring(0, root.IndexOf(':')) +
                                                  "'")).Get();
     return
         drives.Cast<ManagementObject>().Any(
             drive =>
             drive.GetRelated(DiskStrings.DiskPartition).Cast<ManagementObject>().Any(
                 part =>
                 part.GetRelated(DiskStrings.DiskDrive).Cast<ManagementObject>().Any(
                     device =>
                     new ManagementObjectSearcher(GetScope(),
                                                  new SelectQuery(DiskStrings.MountedStorage,
                                                                  "Lun=" + device["SCSILogicalUnit"] +
                                                                  " and PortNumber=" + device["SCSIPort"] +
                                                                  " and TargetID=" + device["SCSITargetID"]))
                         .Get().Cast<ManagementObject>().Any())));
 }