Rico Salfer
2004-01-27 08:26:04 UTC
Hi,
I'm programming with eVC++ 4 and have the following problem:
My program should use an INI file to read and write several values. To read/write I will use the functions GetProfileString and WriteProfileString (class CWinApp). But each call of this functions failed.
I use the following code (exactly like MSDN and eVC++ helpfile) :
BOOL CMyApp::InitInstance()
{
free((void*) m_pszProfileName );
m_pszProfileName = _tcsdup(_T("/Temp/COMConn.ini"));
// SetRegistryKey("MyApp");
// LoadStdProfileSettings();
....
}
void CDlgClass::ReadIniFile()
{
CString csValue;
....
AfxGetApp()->WriteProfileString(_T("Connect"), // Section
_T("Name"), // Key
_T("MyConnect") ); // Value to write
csValue = AfxGetApp()->GetProfileString(_T("Connect"), // Section
_T("Name"), // Key
_T("Error") ); // Default
....
}
The ini file /Temp/COMConn.ini exists, but each call of WriteProfileString() returns FALSE and each call of GetProfileString() returns "Error".
Why failed every access ?
Please help me (fast).
Thank You
Rico
I'm programming with eVC++ 4 and have the following problem:
My program should use an INI file to read and write several values. To read/write I will use the functions GetProfileString and WriteProfileString (class CWinApp). But each call of this functions failed.
I use the following code (exactly like MSDN and eVC++ helpfile) :
BOOL CMyApp::InitInstance()
{
free((void*) m_pszProfileName );
m_pszProfileName = _tcsdup(_T("/Temp/COMConn.ini"));
// SetRegistryKey("MyApp");
// LoadStdProfileSettings();
....
}
void CDlgClass::ReadIniFile()
{
CString csValue;
....
AfxGetApp()->WriteProfileString(_T("Connect"), // Section
_T("Name"), // Key
_T("MyConnect") ); // Value to write
csValue = AfxGetApp()->GetProfileString(_T("Connect"), // Section
_T("Name"), // Key
_T("Error") ); // Default
....
}
The ini file /Temp/COMConn.ini exists, but each call of WriteProfileString() returns FALSE and each call of GetProfileString() returns "Error".
Why failed every access ?
Please help me (fast).
Thank You
Rico