#include #include "SysInfo/SysInfo.h" #include "SysInfo_demo_gui.h" #include #define IMAGEFILE #define IMAGECLASS Images #include #define LAYOUTFILE using namespace Upp; GUI_APP_MAIN { SysInfoDemo program; SetLanguage(LNGC_('E','N','U','S', CHARSET_UTF8)); program.Run(); } void SpecialFolders::Fill() { TextDesktop = GetDesktopFolder(); TextPrograms = GetProgramsFolder(); TextApplication = GetAppDataFolder(); TextMusic = GetMusicFolder(); TextPictures = GetPicturesFolder(); TextVideo = GetVideoFolder(); TextPersonal = GetPersonalFolder(); TextTemplates = GetTemplatesFolder(); TextDownload = GetDownloadFolder(); TextTemp = GetTempFolder(); TextOs = GetOsFolder(); TextSystem = GetSystemFolder(); DefaultExes.Reset(); DefaultExes.AddColumn("Extension", 5); DefaultExes.AddColumn("Program", 40); const char *ext[] = {".html", ".doc", ".png", ".pdf", ".txt", ".xyz", ""}; for (int i = 0; *ext[i] != 0; ++i) DefaultExes.Add(ext[i], GetExtExecutable(ext[i])); #if defined(PLATFORM_WIN32) ButInstalledSoftware.WhenPush = THISBACK(ButInstalledSoftware_Push); #else SoftwareInstalled.Enable(false); ButInstalledSoftware.Enable(false); #endif } void SpecialFolders::ButInstalledSoftware_Push() { #if defined(PLATFORM_WIN32) ButInstalledSoftware.SetLabel("Getting list ..."); ButInstalledSoftware.ProcessEvents(); SoftwareInstalled.Reset(); SoftwareInstalled.AddColumn("Name", 60); SoftwareInstalled.AddColumn("Version", 15); SoftwareInstalled.AddColumn("Vendor", 30); SoftwareInstalled.AddColumn("Install Date", 15); SoftwareInstalled.AddColumn("Caption", 60); SoftwareInstalled.AddColumn("Description", 60); SoftwareInstalled.AddColumn("Install State", 10); Array name, version, vendor, caption, installDate, description, state; if (GetPackagesInfo(name, version, vendor, installDate, caption, description, state)) { for (int i = 0; i < name.GetCount(); ++i) SoftwareInstalled.Add(name[i], version[i], vendor[i], installDate[i], caption[i], description[i], state[i]); } ButInstalledSoftware.SetLabel("Get installed software list"); #endif } void SystemInfo::Fill() { String manufacturer, productName, version, mbSerial; Date releaseDate; int numberOfProcessors; GetSystemInfo(manufacturer, productName, version, numberOfProcessors, mbSerial); TextManufacturer = manufacturer; TextProductName = productName; TextVersion = version; TextNumber = FormatInt(numberOfProcessors); TextSpeed = Format("%.3f GHz", GetCpuSpeed()/1000.); TextTemperature = FormatDouble(GetCpuTemperature()); bool discharging; int percentage, remainingMin; if (GetBatteryStatus(discharging, percentage, remainingMin)) { TextAC = discharging ? "Off" : "On"; if (!IsNull(remainingMin)) TextRemaining = FormatInt(remainingMin) + " min"; else TextRemaining = ""; } TextMotherboardSerial = mbSerial; String biosVersion, biosSerial; Date biosReleaseDate; GetBiosInfo(biosVersion, biosReleaseDate, biosSerial); TextBiosVersion = biosVersion; TextBiosRelease = AsString(biosReleaseDate); TextBiosSerial = biosSerial; String kernel, kerVersion, kerArchitecture, distro, distVersion, desktop, deskVersion; if (GetOsInfo(kernel, kerVersion, kerArchitecture, distro, distVersion, desktop, deskVersion)) { TextKernel = kernel; TextKerVersion = kerVersion; TextKerArchitecture = kerArchitecture; TextDistro = distro; TextDistVersion = distVersion; TextDesktop = desktop; TextDeskVersion = deskVersion; } String nname, domain, ip4, ip6; if (GetNetworkInfo(nname, domain, ip4, ip6)) { Textnname = nname; TextDomain = domain; TextIp4 = ip4; TextIp6 = ip6; } int memoryLoad; uint64 totalPhys, freePhys, totalPageFile, freePageFile, totalVirtual, freeVirtual; if (GetMemoryInfo(memoryLoad, totalPhys, freePhys, totalPageFile, freePageFile, totalVirtual, freeVirtual)) { TextMemPercentage = FormatInt(memoryLoad); TextMemTotPhysicalbytes = Format64(totalPhys); TextMemTotPhysical = BytesToString(totalPhys); TextMemFreePhysicalbytes = Format64(freePhys); TextMemFreePhysical = BytesToString(freePhys); TextMemTotPagingbytes = Format64(totalPageFile); TextMemTotPaging = BytesToString(totalPageFile); TextMemFreePagingbytes = Format64(freePageFile); TextMemFreePaging = BytesToString(freePageFile); TextMemTotVirtualbytes = Format64(totalVirtual); TextMemTotVirtual = BytesToString(totalVirtual); TextMemFreeVirtualbytes = Format64(freeVirtual); TextMemFreeVirtual = BytesToString(freeVirtual); } String compiler, mode; Time tim; int compilerVersion, bits; GetCompilerInfo(compiler, compilerVersion, tim, mode, bits); TextCompiler = compiler; TextCompilerVersion = FormatInt(compilerVersion); TextCompilationDate = Format(tim); TextCompilationMode = mode; TextCompilationBits = FormatInt(bits); Processors.Reset(); Processors.AddColumn("Processor", 6); Processors.AddColumn("Vendor", 12); Processors.AddColumn("Identifier", 40); Processors.AddColumn("Architecture", 30); Processors.AddColumn("Speed MHz", 10); String vendor, identifier, architecture; int speed; for (int i = 0; i < numberOfProcessors; ++i) { GetProcessorInfo(i, vendor, identifier, architecture, speed); Processors.Add(Format("#%d", i), vendor, identifier, architecture, FormatInt(speed)); } #if defined(PLATFORM_WIN32) Video.Reset(); Video.AddColumn("Name", 10); Video.AddColumn("Description", 10); Video.AddColumn("Video Processor", 10); Video.AddColumn("Adapter RAM Mb", 6); Video.AddColumn("Video Mode Description", 10); Array name, description, videoProcessor, videoMode, ram; if (GetVideoInfo(name, description, videoProcessor, ram, videoMode)) { for (int i = 0; i < name.GetCount(); ++i) Video.Add(name[i], description[i], videoProcessor[i], ram[i], videoMode[i]); } else Video.Add("Video data not accesible"); #else Video.Enable(false); #endif Drives.Reset(); Drives.AddColumn("Path", 10); Drives.AddColumn("Type", 10); Drives.AddColumn("Volume", 10); Drives.AddColumn("Max name", 5); Drives.AddColumn("File System", 5); Drives.AddColumn("Total User bytes", 10); Drives.AddColumn("Total User", 6); Drives.AddColumn("Free User bytes", 10); Drives.AddColumn("Free User", 6); Drives.AddColumn("Total Free bytes", 10); Drives.AddColumn("Total Free", 6); Vector drives; drives = GetDriveList(); for (int i = 0; i < drives.GetCount(); ++i) { Vector row; row.Clear(); row.Add(drives[i]); String type, volume, fileSystem; int maxName; bool mounted = GetDriveInformation(drives[i], type, volume, maxName, fileSystem); if (mounted) { row.Add(type); row.Add(volume); row.Add(maxName); row.Add(fileSystem); uint64 freeBytesUser, totalBytesUser, totalFreeBytes; if(!GetDriveSpace(drives[i], freeBytesUser, totalBytesUser, totalFreeBytes)) row.Add("Installed but no access to drive"); else { row.Add(Format64(totalBytesUser)); row.Add(BytesToString(totalBytesUser)); row.Add(Format64(freeBytesUser)); row.Add(BytesToString(freeBytesUser)); row.Add(Format64(totalFreeBytes)); row.Add(BytesToString(totalFreeBytes)); } } else row.Add("Not mounted"); Drives.Add(row); } Adapters.Reset(); Adapters.AddColumn("Type", 10); Adapters.AddColumn("Description", 20); Adapters.AddColumn("Fullname", 20); Adapters.AddColumn("MAC", 10); Adapters.AddColumn("IP4", 10); Adapters.AddColumn("IP6", 10); Array adapters = GetAdapterInfo(); for (int i = 0; i < adapters.GetCount(); ++i) Adapters.Add(adapters[i].type, adapters[i].description, adapters[i].fullname, adapters[i].mac, adapters[i].ip4, adapters[i].ip6); ButUpdate.WhenPush = THISBACK(ButUpdate_Push); } void SystemInfo::ButUpdate_Push() { Fill(); } #if defined(PLATFORM_WIN32) || defined (PLATFORM_WIN64) #define SetBit(uIntFlagBuff, Bit) (uIntFlagBuff |= (Bit)) #define ClearBit(uIntFlagBuff, BitNum) (uIntFlagBuff = ((uIntFlagBuff) | (BitNum)) ^ (BitNum) ) static const char *styles[] = {"WS_CAPTION","WS_BORDER","WS_TABSTOP","WS_CHILD","WS_THICKFRAME","WS_VISIBLE","WS_VSCROLL","WS_HSCROLL","WS_SYSMENU","WS_SIZEBOX","WS_POPUP","WS_MINIMIZE","WS_MAXIMIZE","WS_MINIMIZEBOX","WS_MAXIMIZEBOX","WS_GROUP","WS_DLGFRAME","WS_CLIPSIBLINGS","WS_CLIPCHILDREN","WS_CHILDWINDOW","WS_DISABLED"}; static const uint64 stylesbits[] = {WS_CAPTION,WS_BORDER,WS_TABSTOP,WS_CHILD,WS_THICKFRAME,WS_VISIBLE,WS_VSCROLL,WS_HSCROLL,WS_SYSMENU,WS_SIZEBOX,WS_POPUP,WS_MINIMIZE,WS_MAXIMIZE,WS_MINIMIZEBOX,WS_MAXIMIZEBOX,WS_GROUP,WS_DLGFRAME,WS_CLIPSIBLINGS,WS_CLIPCHILDREN,WS_CHILDWINDOW,WS_DISABLED}; static const char *exstyles[] = {"WS_EX_ACCEPTFILES","WS_EX_APPWINDOW","WS_EX_CLIENTEDGE","WS_EX_COMPOSITED","WS_EX_CONTROLPARENT","WS_EX_DLGMODALFRAME","WS_EX_LAYERED","WS_EX_LAYOUTRTL","WS_EX_LEFTSCROLLBAR","WS_EX_MDICHILD","WS_EX_NOACTIVATE","WS_EX_NOINHERITLAYOUT","WS_EX_NOPARENTNOTIFY"/*,"WS_EX_NOREDIRECTIONBITMAP"*/,"WS_EX_RIGHT","WS_EX_PALETTEWINDOW(WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW|WS_EX_TOPMOST)","WS_EX_STATICEDGE","WS_EX_TOOLWINDOW","WS_EX_TOPMOST","WS_EX_TRANSPARENT","WS_EX_WINDOWEDGE"}; static const uint64 exstylesbits[] = {WS_EX_ACCEPTFILES,WS_EX_APPWINDOW,WS_EX_CLIENTEDGE,WS_EX_COMPOSITED,WS_EX_CONTROLPARENT,WS_EX_DLGMODALFRAME,WS_EX_LAYERED,WS_EX_LAYOUTRTL,WS_EX_LEFTSCROLLBAR,WS_EX_MDICHILD,WS_EX_NOACTIVATE,WS_EX_NOINHERITLAYOUT,WS_EX_NOPARENTNOTIFY/*,WS_EX_NOREDIRECTIONBITMAP*/,WS_EX_RIGHT,WS_EX_PALETTEWINDOW,WS_EX_STATICEDGE,WS_EX_TOOLWINDOW,WS_EX_TOPMOST,WS_EX_TRANSPARENT,WS_EX_WINDOWEDGE}; struct SOptDropGrid: public DropGrid { int64 hwnd; ArrayOption option; typedef SOptDropGrid CLASSNAME; SOptDropGrid() { hwnd = 0; ClearButton(); //AddPlus(THISBACK(action)); AddColumn("Style", 60).Ctrls