我尝试使用以下代码在 Code::Blocks IDE 中使用 C 语言从 Windows 获取 GUID:
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <stdio.h>
void getHWID()
{
HW_PROFILE_INFO hwProfileInfo;
if(GetCurrentHwProfile(&hwProfileInfo))
{
printf("Hardware GUID: %s\n", hwProfileInfo.szHwProfileGuid);
printf("Hardware Profile: %s\n", hwProfileInfo.szHwProfileName);
}
}
即使我链接并包含所需的所有文件,我仍然收到这些错误:
In function 'getHWID': warning: implicit declaration of function 'GetCurrentHwProfile'
In function
getHWID': undefined reference to
GetCurrentHwProfile'||=== Build finished: 1 errors, 1 warnings ===|
如果有人遇到过这个问题或知道如何解决它,请告诉我。另外,如果我右键单击 HW_PROFILE_INFO
或 GetCurrentHwProfile
并单击查找声明,它会显示未找到。
我想让这个工作正常进行,但我也愿意接受其他简单的方法来完成这个工作。
编辑:我现在已经包含了 Winbase.h,它找到了 HW_PROFILE_INFO
的声明,但我仍然收到 GetCurrentHwProfile
的 undefined reference 错误
最佳答案
您是否已配置 Code::Blocks 以包含正确的 SDK(我相信此函数是 Windows SDK 的一部分)?我建议使用 Microsoft Visual Studio 编写 Windows 代码。
编辑:我不确定这是否是您需要做的全部,但是他们的 wiki 中有一个部分关于如何使用微软的编译器。
关于c - Code::Blocks 中的 GetCurrentHwProfile (C),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5616391/