使用GetPrivateProfileInt,GetPrivateProfileString读取十六进制值的正确方法是什

What is the proper way to read hexadecimal values using GetPrivateProfileInt, GetPrivateProfileString?

本文关键字:方法 GetPrivateProfileInt GetPrivateProfileString 读取 十六进制 使用      更新时间:2023-10-16

现在我想从 ini 内部的变量中获取值,并将它们吐到 sendkey 函数上。所以目前这就是我在顶部定义它们的方式,显然不正确,因为我在测试变量时获得了默认值。

const int KeyAtk = GetPrivateProfileInt(L"BotSettings",L"AttackKey", 0xA2, L"config.ini");
const int KeyLoot = GetPrivateProfileInt(L"BotSettings",L"LootKey", 0x5A, L"config.ini");
//Counts
int CntAtk = GetPrivateProfileInt(L"BotSettings",L"PressAttack", 25, L"config.ini");
int CntLoot = GetPrivateProfileInt(L"BotSettings",L"PressLoot", 15, L"config.ini");

前面带有 const int 的值具有十六进制值,如 0xA2 和 0x5A,它们只是虚拟键代码。我希望能够随时更改此密钥,这就是为什么我不仅在sendkey函数中使用它,任何对如何让GetPrivateProfileInt读取十六进制值有想法的人。

GetPrivateProfileInt不支持

十六进制。如果要支持十六进制,则必须调用GetPrivateProfileString并自行解析。