views:

30

answers:

1

IDE: VS2005

Is there anyway to know why ReadFile() failed? I can't find the reason some of the INI can't be read. Thanks.

EDIT:

CIniFile iniFile;
iniFile.SetPath( "C:\\Services\\Server\\Server.INI" );
if( iniFile.ReadFile())
    my code...

The program never gets in the if block.

And, sorry for the confusing. I use this library for the CIniFile class. Hope this information helps to pinpoint the problem. http://www.codeproject.com/kb/cpp/cinifileByCabadam.aspx

EDIT2: I found the reason, it's because some of the ini files are saved as Unicode. And that's the reason ReadFile() fails. But now the question is how to read Unicode ini files.

+1  A: 

Normally GetLastError() should give you an error number to look up

EDIT: In the CIniFile project there seems to be no default constructor, try instead CIniFile( string const iniPath ) i.e.

CIniFile iniFile( "C:\\Services\\Server\\Server.INI" );
if( iniFile.ReadFile())

EDIT2: OK, you would need to modify the code to instead of using fstream use wfstream - see

Anders K.