I am trying to create a program that makes a file called hardware id txt when non is present, but if it is it will look inside of it and find the hardware id, if it matches then it will print something, right now i am trying to output whats in the file first to test, no errors but the hardware id does not appear in console, i checked the file and can confirm the hardware id is inside of it.
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
HW_PROFILE_INFO hwProfileInfo; // unless we have a very good reason, this should
// not be global
if(GetCurrentHwProfile(&hwProfileInfo) != NULL)
{ // update info was a success. NOW we have a GUID and can do stuff with
// hwProfileInfo
printf("Hardware GUID: %s\n", hwProfileInfo.szHwProfileGuid);
printf("Hardware Profile: %s\n", hwProfileInfo.szHwProfileName);
std::ofstream hwidfile { "hardwareid2.txt" };
if (!(hwidfile << hwProfileInfo.szHwProfileGuid))
{ // will fail if can't write for any reason, like file didn't open
std::cout << "File write failed\n";
return -1;
}
}
else
{
std::cout << "GetCurrentHwProfile failed\n";
return -1;
}
getchar();
}
int check()
{
HW_PROFILE_INFO hwProfileInfo;
if(GetCurrentHwProfile(&hwProfileInfo) != NULL) {
string line;
ifstream checkhwid("hardwareid2.txt");
while(getline(checkhwid, line)) {
cout << line;
}
checkhwid.close();
}
}