讀ini檔案——“GetPrivateProfileIntW”: 不能将參數 1 從“const char [9]
用GetPrivateProfileInt讀取ini配置檔案:
std::string iniPath;
test = GetPrivateProfileInt("Performance", "Type", 0, iniPath.c_str());
總是出錯:
error C2664: 'GetPrivateProfileIntW' : cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR'
解決辦法:
選中項目,右鍵選擇屬性——>配置屬性——>正常——>項目預設值——>字元集,選為“使用多位元組字元集"——>應用——>确定。
重新編譯,可以發現錯誤已消除。