Question

I'm creating a dll on c++. It is a Visual Studio project. The dll reads some data from ini file. I have decided to use GetPrivateProfileString function. It works almost completely. It does not see file in current directory. How can I provide this parameter (variable called path)?

How can I pass last parameter (path)

Code:

LPCTSTR path = L"\\test.ini";
TCHAR protocolChar[32];
int a = GetPrivateProfileString(_T("Connection"), _T("Protocol"), _T(""), protocolChar, 32, path);

String from test.ini:

[Connection]
Protocol = HTTP

I also tried this:

LPCTSTR path = L"test.ini";

But it did not help me

Was it helpful?

Solution

LPCTSTR path = _T(".\\test.ini");

. symbolises current directory. Hope this will work for you.

OTHER TIPS

WCHAR   cfg_IniName[256];         

GetCurrentDirectory (MAX_PATH, cfg_IniName );    

wcscat ( cfg_IniName, L"\\test.ini" );  

way to get full path

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top