Information
WMI Access
This is a seperate program written in C#.net that is used to access WMI information to gather more detailed information about a computer or server. This is project is intended to be fully integrated into Dynamite DNS in the near future. Here is the source code and a video explaining it (video uses older source code, updated project to use Win32_LogicalDisk):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;namespace WMIAccess
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("hello peoples here are the disk infos:");
string Name = "", Description = "", FileSystem = "", FreeSpace = "", Capacity = "", Serial = "";
double frespc, cap;
// Get all the disk drives
//ADD THIS IN FUTURE Win32_TemperatureProbeManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk");
// Loop through each object (disk) retrieved by WMI
Console.WriteLine("**-------------------------------------**");
foreach (ManagementObject moDisk in mosDisks.Get())
{
try
{
// Add the HDD to the list (use the Model field as the item's caption)
// Set all the fields to the appropriate values
Name = "Name: " + moDisk["Name"].ToString() + moDisk["VolumeName"].ToString();
Description = "Description: " + moDisk["Description"].ToString();
FileSystem = "FileSystem: " + moDisk["FileSystem"].ToString();
frespc = Convert.ToDouble(moDisk["FreeSpace"].ToString()) / 1073741824;
cap = Convert.ToDouble(moDisk["Size"].ToString()) / 1073741824;
FreeSpace = "FreeSpace: " + Math.Round(frespc,1).ToString()+ " GB";
Capacity = "Capacity: " + Math.Round(cap, 1).ToString() + " GB";
Serial = "Serial: " + moDisk["VolumeSerialNumber"].ToString();
Console.WriteLine(Name);
Console.WriteLine(Description);
Console.WriteLine(FileSystem);
Console.WriteLine(FreeSpace);
Console.WriteLine(Capacity);
Console.WriteLine(Serial);}
catch (System.Exception)
{
Console.WriteLine("Error reading device information, skipping to next device.");
}
Console.WriteLine("**-------------------------------------**");
}System.Threading.Thread.Sleep(200000);
}
}
}
