Using Microsoft. Win32;
Private int getcpufrequency ()
{
Registrykey rk = registry. localmachine. opensubkey (@ "Hardware \ description \ System \ centralprocessor \ 0 ");
Object OBJ = rk. getvalue ("~ MHz ");
Int cpufrequency = (INT) OBJ;
Return cpufrequency;
}
//////////////////////////////////
// Disk space management
Using system. Management;
Private long getfreediskspace ()
{
Managementobject disk = new managementobject (
"Win32_logicaldisk.deviceid = \" D :\"");
Disk. Get ();
String totalbyte = disk ["freespace"]. tostring ();
Long freediskspacemb = converter. toint64 (totalbyte)/1024/1024;
Return freediskspacemb;
}
/////////////////////
// Memory information
Using system;
Using system. text;
Using system. runtime. interopservices;
Namespace consoleapplication1
{
/** // <Summary>
/// Summary description for class1.
/// </Summary>
Class class1
{
[Structlayout (layoutkind. Sequential)]
Public struct memory_info
{
Public uint dwlength;
Public uint dwmemoryload;
Public uint dwtotalphys;
Public uint dwavailphys;
Public uint dwtotalpagefile;
Public uint dwavailpagefile;
Public uint dwtotalvirtual;
Public uint dwavailvirtual;
}
[Dllimport ("Kernel32")]
Public static extern void globalmemorystatus (ref memory_info meminfo );
Public static int main (string [] ARGs)
{
Class1 class1 = new class1 ();
Class1.getmemorystatus ();
Return 0;
}
Private void getmemorystatus ()
{
Memory_info meminfo;
Meminfo = new memory_info ();
Globalmemorystatus (ref meminfo );
Long totalmb = convert. toint64 (meminfo. dwtotalphys. tostring ()/1024/1024;
Long avaliablemb = convert. toint64 (meminfo. dwavailphys. tostring ()/1024/1024;
Console. writeline ("total physical memory" + totalmb + "MB ");
Console. writeline ("available physical memory" + avaliablemb + "MB ");
}
}
//////////////////////////////
// CPU name
Using Microsoft. Win32;
Private string getcpuname ()
{
Registrykey rk = registry. localmachine. opensubkey (@ "Hardware \ description \ System \ centralprocessor \ 0 ");
Object OBJ = rk. getvalue ("processornamestring ");
String cpuname = (string) OBJ;
Return cpuname. trimstart ();
}
///////////////////////
// OS version
Using system;
Namespace determineos_cs
{
Class class1
{
Static void main (string [] ARGs)
{
// Get operatingsystem information from the system namespace.
System. operatingsystem osinfo = system. environment. osversion;
// Determine the platform.
Switch (osinfo. Platform)
{
// Platform is Windows 95, Windows 98,
// Windows 98 Second edition, or Windows ME.
Case System. platformid. win32windows:
Switch (osinfo. version. Minor)
{
Case 0:
Console. writeline ("Windows 95 ");
Break;
Case 10:
If (osinfo. version. Revision. tostring () = "2222a ")
Console. writeline ("Windows 98 Second Edition ");
Else
Console. writeline ("Windows 98 ");
Break;
Case 90:
Console. writeline ("Windows ME ");
Break;
}
Break;
// Platform is Windows NT 3.51, Windows NT 4.0, Windows 2000,
// Or Windows XP.
Case System. platformid. win32nt:
Switch (osinfo. version. Major)
{
Case 3:
Console. writeline ("Windows NT 3.51 ");
Break;
Case 4:
Console. writeline ("Windows NT 4.0 ");
Break;
Case 5:
If (osinfo. version. Minor = 0)
Console. writeline ("Window 2000 ");
Else
Console. writeline ("Windows XP ");
Break;
} Break;
}
Console. Readline ();
}
}
}