#include <iostream>
#include <windows.h>
#include <psapi.h>
void GetDiskSpace()
{
ULARGE_INTEGER totalBytes, freeBytes, usedBytes;
if (GetDiskFreeSpaceEx(NULL, &freeBytes, &totalBytes, &usedBytes))
{
std::cout << "Capacidad total del disco: " << totalBytes.QuadPart / (1024 * 1024) << " MB" << std::endl;
std::cout << "Espacio libre en el disco: " << freeBytes.QuadPart / (1024 * 1024) << " MB" << std::endl;
std::cout << "Espacio utilizado en el disco: " << usedBytes.QuadPart / (1024 * 1024) << " MB" << std::endl;
}
}
void GetMemoryUsage()
{
MEMORYSTATUSEX memoryStatus;
memoryStatus.dwLength = sizeof(memoryStatus);
if (GlobalMemoryStatusEx(&memoryStatus))
{
std::cout << "Memoria RAM total: " << memoryStatus.ullTotalPhys / (1024 * 1024) << " MB" << std::endl;
std::cout << "Memoria RAM libre: " << memoryStatus.ullAvailPhys / (1024 * 1024) << " MB" << std::endl;
std::cout << "Memoria RAM utilizada: " << (memoryStatus.ullTotalPhys - memoryStatus.ullAvailPhys) / (1024 * 1024) << " MB" << std::endl;
}
}
void GetPortCount()
{
DWORD portCount = 0;
if (GetNumberOfConsoleInputEvents(&portCount))
{
std::cout << "Número de puertos: " << portCount << std::endl;
}
}
void GetDriveCount()
{
DWORD driveCount = GetLogicalDrives();
std::cout << "Número de unidades de disco: " << __popcnt(driveCount) << std::endl;
}
void ShowDirectoryAttributes(const std::string& directory)
{
WIN32_FIND_DATAA fileData;
HANDLE hFind = FindFirstFileA((directory + "\\*").c_str(), &fileData);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
std::cout << "Nombre: " << fileData.cFileName << std::endl;
std::cout << "Atributos: " << fileData.dwFileAttributes << std::endl;
std::cout << std::endl;
} while (FindNextFileA(hFind, &fileData));
FindClose(hFind);
}
}
int main()
{
GetDiskSpace();
GetMemoryUsage();
GetPortCount();
GetDriveCount();
ShowDirectoryAttributes("C:\\Directorio"); // Reemplaza "C:\\Directorio" con el directorio que deseas mostrar
return 0;
}