c++ - GetCurrentHwProfile was not declared in this scope using MinGW's g++ compiler -


I am trying to get the hardware GUID, and I found this function posted on the web. #define _WIN32_WINNT 0x0400 #include & lt; Windows.h & gt; # Include & lt; Stdio.h & gt; # Include & lt; Tchar.h & gt; Int main () {HW_PROFILE_INFO hwProfileInfo; If (GetCurrentHwProfile (& amp; hwProfileInfo)! = NULL) {printf ("Hardware GUID:% s \ n", hwProfileInfo.szHwProfileGuid); Printf ("Hardware Profile:% s \ n", hwProfileInfo.szHwProfileName); } And {return 0; } By (); }

The problem is, whenever I try to compile it, I get "error: 'GetCurrentHwProfile' was not declared in this area". Maybe I'm using MinziW's G ++, maybe this is the problem?

Good catch! (If you can call it)

The problem is that GetCurrentHwProfile will usually be a small cut, if you want to convert it to GetCurrentHwProfileW while compiling with Unicode support. Otherwise, it turns into GetCurrentHwProfileA.

Solution? Just add one at the end Ie GetCurrentHwProfileA :)

BB.bbut - Remember that you have to change it clearly if you decide to use Unicode after all, be a very clean solution See if GetCurrentHwProfile is as necessary as correct. I think it is probably done with something: (It's still lazy to see. All windows functions use this trick, it looks like Mingu Crowd this small I remember Gemini who is GetCurrentHwProfile)

  #ifdef UNICODE #define GetCurrentHwProfile GetCurrentHwProfileW #else #define GetCurrentHwProfile GetCurrentHwProfileA #endif    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -