Trying to implement HWID Checker

I want to check if hwid serial code (HWID) is valid from std::vector<std::string> list but I can't get it to work. Here is what I have tried.
however, it does not seem to work. It does not return it false even if hwid is not found.
any better methods (open source)?



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 HW_PROFILE_INFO hwProfileInfo; // GET HWID
if (GetCurrentHwProfile(&hwProfileInfo))
    printf("HWID: %sn", hwProfileInfo.szHwProfileGuid);


std::vector<std::string> vKeyUser = {
  "",
  "f8d56296-a455-11eb-9669-80646f676963",
  "f8d5d90w6-a125-11eb-9629-89d06f6e6963",
  "etc",
  "etc",
  "etc"
};

bool checkHwid()
{
 bool status= false;
 std::string system_key =  hwProfileInfo.szHwProfileGuid;
 for(size_t i  = 0; i < vKeyUser.size(); i++)
 {
    if(vKeyUser[i] == system_key){
	  status= true;
	  break;
	}
 }
  return status;
}
 
 
 
int main()
    {
    	if (!checkHwid())
    		return NULL;
    }
The string returned by GetCurrentHwProfile encloses the GUID in curly braces[...]
https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-hw_profile_infow

The sample program is unnecessarily complicated.

You could have saved time by reading the manual before asking.
Last edited on
Topic archived. No new replies allowed.