[英]GetPrivateprofilestring does not get an ini file in current directory
[英]c++ GetPrivateProfileString read ini file from current directory
我在c ++上創建一個dll。 它是一個Visual Studio項目。 dll從ini文件中讀取一些數據。 我決定使用GetPrivateProfileString函數。 它幾乎完全有效。 它沒有在當前目錄中看到文件。 如何提供此參數(稱為路徑的變量)?
如何傳遞最后一個參數(路徑)
碼:
LPCTSTR path = L"\\test.ini";
TCHAR protocolChar[32];
int a = GetPrivateProfileString(_T("Connection"), _T("Protocol"), _T(""), protocolChar, 32, path);
test.ini中的字符串:
[Connection]
Protocol = HTTP
我也試過這個:
LPCTSTR path = L"test.ini";
但它沒有幫助我
LPCTSTR path = _T(".\\test.ini");
.
象征當前目錄。 希望這對你有用。
WCHAR cfg_IniName[256];
GetCurrentDirectory (MAX_PATH, cfg_IniName );
wcscat ( cfg_IniName, L"\\test.ini" );
獲得完整路徑的方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.