Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Management;
- namespace WMITest
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- MessageBox.Show(Dump());
- }
- string Dump()
- {
- string HOST = "WILLIAM-PC";
- string Data = "";
- try
- {
- ConnectionOptions CO = new ConnectionOptions();
- CO.Authentication = AuthenticationLevel.Packet;
- ManagementScope Scope = new ManagementScope(@"\\" + HOST + @"\root\cimv2", CO);
- Scope.Connect();
- if (! Scope.IsConnected)
- {
- MessageBox.Show("Not connected!");
- }
- Scope.Options.EnablePrivileges = true;
- SelectQuery Query = new SelectQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Memory");
- ManagementObjectSearcher MOS = new ManagementObjectSearcher(Scope, Query);
- foreach (ManagementObject MO in MOS.Get())
- {
- foreach (PropertyData PD in MO.Properties)
- {
- Data = Data + PD.Name + " = " + PD.Value + "\n";
- }
- }
- return Data;
- }
- catch (Exception E)
- {
- return "Exception: " +E.Message ;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement