質問:GetPrivateProfileIntメソッドのパスパラメーターとしてstring/char * variableを使用する方法。GetPrivateProfileIntメソッドのパラメーター
窓にはGetPrivateProfileIntを使用しようとしています。次のコードは、いかなる問題なく動作しますperfeclty:
int x = GetPrivateProfileInt(L"x",L"y",1,L"This\\is\\the\\path");
しかし、私の場合には、パスが関数に渡されています。このようなもの:
xはデフォルト値を受け取ります。つまり、パスが正しくGetPrivateProfileIntメソッドに渡されていないことを示します。続き
は私によって作られた他のいくつかの試みです:
Attempt1:
// No error, default value is being read.
int x = GetPrivateProfileInt(L"x",L"y",1,(LPCTSTR)path.c_str());
Attempt2:
// No error, default value is being read.
int x = GetPrivateProfileInt(L"x",L"y",1,(wchar_t*)path.c_str());
Attempt3:
//_T() macro giving error.
// 'Ls' : undeclared identifier.identifier "Ls" is undefined.
LPCTSTR path_s = _T(path.c_str());
int x = GetPrivateProfileInt(L"x",L"y",1,path_s);
答えはhereでしたが、解決策を見つけることができませんでした。
動作するかどうかを確認してください。 – Shasha99
ありがとうございます。出来た !!! – Shasha99