0

I would like to make a Windows Desktop application that is checking the hardware ID of currently used PC. I'm using VS2019 and created a "CLR Empty Project (.NET Framework)". I created a new C++ file with exemplary code available on learn.microsoft:

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

void main(void) 
{
   HW_PROFILE_INFO   HwProfInfo;
   if (!GetCurrentHwProfile(&HwProfInfo)) 
   {
      _tprintf(TEXT("GetCurrentHwProfile failed with error %lx\n"), 
                 GetLastError());
      return;
   }
   _tprintf(TEXT("DockInfo = %d\n"), HwProfInfo.dwDockInfo);
   _tprintf(TEXT("Profile Guid = %s\n"), HwProfInfo.szHwProfileGuid);
   _tprintf(TEXT("Friendly Name = %s\n"), HwProfInfo.szHwProfileName);
}

Then I get the problems in this image: Error Message When I do the same with an "Empty C++ Project" everything works as expected.

I would be really happy if someone could explain what's the problem and how to solve this. Thanks!

Andy

Andreas
  • 1
  • 1
  • If you read [the `GetCurrentHwProfile` documentation](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrenthwprofilea) it will tell you that you need to link with the `Advapi32` library. This library is usually not linked by default. – Some programmer dude Jan 05 '23 at 07:35
  • Please post error messages as text from the compiler output window, not screenshots of the error list – Alan Birtles Jan 05 '23 at 07:42

0 Answers0