GetCurrentHwProfile 未使用 MinGW 的 g++ 编译器在此范围内声明
GetCurrentHwProfile was not declared in this scope using MinGW's g++ compiler
我一直在试图获得硬件GUID,我发现这个函数张贴在网上。
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
int main()
{
HW_PROFILE_INFO hwProfileInfo;
if(GetCurrentHwProfile(&hwProfileInfo) != NULL){
printf("Hardware GUID: %sn", hwProfileInfo.szHwProfileGuid);
printf("Hardware Profile: %sn", hwProfileInfo.szHwProfileName);
}else{
return 0;
}
getchar();
}
问题是,每当我试图编译它,我得到"错误:'GetCurrentHwProfile'未在此范围内声明"。我用的是MinGW的g++。也许这就是问题所在?
接得好!(如果你能这么叫的话)
问题是通常GetCurrentHwProfile将是一个快捷方式,如果你喜欢。当使用UNICODE支持编译时,它被更改为GetCurrentHwProfileW。否则,它将被更改为GetCurrentHwProfileA。
解决方案吗?只要在末尾加个A就行了。即GetCurrentHwProfileA:)
BB.b.b。但是-记住,如果您最终决定使用unicode,则必须显式地更改它。更简洁的解决方案是让GetCurrentHwProfile根据需要引用正确的文件。我猜它可能是这样做的:(现在懒得看。所有的窗口函数都使用这个技巧,我猜minGW的人错过了这个小宝石,那就是GetCurrentHwProfile)
#ifdef UNICODE
#define GetCurrentHwProfile GetCurrentHwProfileW
#else
#define GetCurrentHwProfile GetCurrentHwProfileA
#endif
函数GetCurrentHwProfile()
在winbase.h
头中声明:
WINBASEAPI BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA);
WINBASEAPI BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW);
注意,它是GetCurrentHwProfileA
(Ansi)或GetCurrentHwProfileW
(Unicode/宽字符)。我找不到将GetCurrentHwProfile
别名为两个函数中的任何一个的宏的迹象,这取决于定义的UNICODE
。
GetCurrentHwProfileA
或GetCurrentHwProfileW
,或者像
#ifdef UNICODE
#define GetCurrentHwProfile GetCurrentHwProfileW
#else
#define GetCurrentHwProfile GetCurrentHwProfileA
#endif
相关文章:
- 错误:未在此范围内声明'reverse'
- 错误:"imread"未在此范围内声明
- 未在此范围内声明错误 'xy'
- Socklen_t未在此范围内声明
- 错误:'[' 之前预期的非限定 id 和错误:'users'未在此范围内声明
- "Main"已在当前范围内声明
- c++ 变量在宏的扩展中没有在这个范围内声明
- C++ 在编译过程中 strtok 函数 Eclipse 说没有在范围内声明?
- 'num1'未在此范围内声明
- 如何找到在本地范围内声明的变量的地址?
- NT状态未在此范围内声明
- 变量未在此范围内声明 数组线性搜索
- 包含文件中的 Typdef "未在此范围内声明"
- 'ClassName'和'ClassInstance'未在此范围内声明
- C++ 中的类之间的数据重新循环 - 错误:'<class name>'未在此范围内声明
- 代码作为 C 文件工作,但不作为C++文件,错误:'__builtin_types_compatible_p'未在此范围内声明
- 如何修复错误:"vreinterpretq_u32_f64"未在此范围内声明 - 在Android上使用Eigen构建
- 如何修复C++中的"arrStud未在此范围内声明"错误
- 错误:"SHGetKnownFolderPath"未在此范围内声明
- 错误:'Sprite'未在此范围内声明