Take system information

xiaoxiao2021-03-06  142

#include "stdafx.h" #include "systeminfo.h"

/// Multimedia operation support #include "mmsystem.h" /// Take the disk space function support #include "dos.h" #include "direct.h" /// Take the network card MAC address support #include "nb30.h" #pragma comment (lib, "netapi32.lib") /// Take a list of processes support #include #include "icmp.h"

EXTERN CSTRING Remoteip; // Global Variable: Client Address

#ifdef _debug # undef this_filestatic char this_file [] = __ file __; # Define new debug_new # Endif

/ * Constructor * / csysteminfo :: csysteminfo () {= new char [128]; user = new char [128]; cpu = new char [128]; os = new char [128]; MEM = New char [128]; MEM = New Char [ Mac = new char [128]; mmd = new char [128]; DRV = New char [128]; drvli = new char [128]; resolution = new char [2048] GetMacaddr (); getMemory (); getDisk (); getmmd (); getMonitor (); getos (); getcpu (); getuser (); getDrvlist (); getResolutionList ();}

/ * Destructor * / csysteminfo :: ~ csysteminfo () {delete [] ip; delete [] user; delete [] cpu; delete [] os; delete [] MEM; delete [] mac; delete [] mmd; DELETE [] MON; Delete [] Drv; delete [] drvli; delete [] resolution;}

/ * Function: acquire CPU information * / void CSystemInfo :: GetCpu () {CString m_strCpuInfo; m_strCpuInfo.Empty (); char OEMString [13]; int iEAXValue, iEBXValue, iECXValue, iEDXValue; _asm {mov eax, 0 cpuid mov DWORD PTR oEMString, ebx mov DWORD PTR oEMString 4, edx mov DWORD PTR oEMString 8, ecx mov BYTE PTR oEMString 12,0} m_strCpuInfo.Format ( "% s", oEMString); _asm {mov eax, 1 cpuid mov iEAXValue , eax mov iEBXValue, ebx mov iECXValue, ecx mov iEDXValue, edx} if (iEDXValue & 0x800000) {m_strCpuInfo = "MMX Support";} else {m_strCpuInfo = "No MMX Support";} int iCPUFamily = (0xf00 & iEAXValue) >> 8 ; Cstring m_family; m_family.format ("% s% d", "/ r / n family:", icpufamily); m_strcpuinfo = m_Family; cstract frequency; _int64 start = count (); SLEEP (1000); _int64 stop = count (); Uint cpuspeed = (stop-start) / 1000000); frequency.format ("% D MHz", cpuspeed; cstring cpuinfo; cpuinfo.format ("% s% s", "frequency:" , FREQ Unecy); m_strcpuinfo = cpuinfo; strcpy (cpu, m_strcpuinfo);}

/ * Function: obtaining multimedia device information * / void CSystemInfo :: GetMMD () {int wavedevice, mididevice; CString mmSys; WAVEOUTCAPS wavecap; MIDIOUTCAPS midicap; wavedevice = (int) waveOutGetNumDevs (); mididevice = (int) midiOutGetNumDevs (); IF (WaveDevice == 0) {mmsys = "No waveform device";} else {WaveoutGetDevcaps (0, & Wavecap, Sizeof (WaveoutCaps)); mmsys = "Waveform device:"; mmsys = cstring (Wavecap.szpname);} IF (Mididevice == 0) {mmsys = "No MIDI device";} else {midiOutGetDevcaps (0, & midicap, sizeof (midioutcaps)); mmsys = "MIDI device:"; mmsys = (cstring) midicap.szpname;} STRCPY (MMD, MMSYS);

/ * Function: obtaining information disk space * / void CSystemInfo :: GetDisk () {CString strFreeDiskSpace; struct _diskfree_t diskfree; int nDrive = _getdrive (); while (_getdiskfree (nDrive, & diskfree) == 0) {nDrive ;} nDrive- -; cstring m_diskspace; m_diskspace.empty (); for (int di = 2; di

/ * Function: Number of drive list * / void csysteminfo :: getdrvlist () {cstring m_stdriver; char volume [255], filename [100]; dword sno, maxl, fileflag; char stmp [1]; memory (STMP, 0, 4); Sprintf (STMP, "% s", "a: //"); for (int DRV = 'a'; DRV <= 'Z'; DRV ) {stmp [0] = (char) DRV; IF (GetDriveType (STMP) == 3) {CSTRING DR; Dr.Format ("% S% S", STMP, "#"); m_stdriver = DR;} IF (getDriveType (STMP) == 5) {IF (GetVolumeInformation (STMP, Volname, 255, & Sno, & MaxL, & Fileflag, FileName, 100)) {CSTRING DR; Dr.Format ("% S% S", STMP, "#"); m_stdriver = DR;} m_cd = DRV;} } STRCPY (DRVLI, M_STDRIVER);} / * Function: Get the CPU boot to the number of cycles now * / _ int64 csysteminfo :: count (void) {_ASM {_emit 0x0f _emit 0x31}}

/ * Function: information acquisition memory * / void CSystemInfo :: GetMemory () {CString strFreeMemory; CString strFmt; // Fill available memory MEMORYSTATUS MemStat; MemStat.dwLength = sizeof (MEMORYSTATUS); GlobalMemoryStatus (& MemStat); int m_Mem; m_Mem = MemStat.dwtotalphys / 1024L; m_mem / = 1024; cstring strm; strm.format ("% D MB", M_MEM); strcpy (MEM, STRM);}

转载请注明原文地址:https://www.9cbs.com/read-127284.html

New Post(0)