This commit is contained in:
ENV
2024-08-02 13:27:27 -07:00
parent 5aaeb37042
commit 589c4d57cd
33 changed files with 2059 additions and 0 deletions

33
Utils/hardware.hpp Normal file
View File

@@ -0,0 +1,33 @@
#include <windows.h>
#include <tlhelp32.h>
#include <string>
#include <iostream>
#include "vector.h"
#include <tuple>
#include <cmath>
std::string GetDiskVolumeSerialNumber()
{
char volumeName[MAX_PATH + 1] = { 0 };
char fileSystemName[MAX_PATH + 1] = { 0 };
DWORD serialNumber = 0;
DWORD maxComponentLength = 0;
DWORD fileSystemFlags = 0;
if (GetVolumeInformationA("C:\\", volumeName, ARRAYSIZE(volumeName),
&serialNumber, &maxComponentLength, &fileSystemFlags,
fileSystemName, ARRAYSIZE(fileSystemName)))
{
// Convert serial number to a string
std::string serialNumberStr = std::to_string(serialNumber);
return serialNumberStr;
}
else
{
// Handle error
DWORD error = GetLastError();
std::cerr << "Failed to get volume information. Error code: " << error << std::endl;
return "";
}
}