Click to See Complete Forum and Search --> : reading an INI file (GetPrivateProfileString)


Illusioned
July 6th, 1999, 06:29 PM
Im trying to read an INI file, but it keeps coming up with the default entry.. I know the ini file exists and the key and section im looking for exist.. is there something wrong with this function?

char *ReadINIVal(const char* Section, const char* Key, const char* INIFN)
{
char buffer[2000];
char er[100] = "Could Not Read Initialization Value: ";
BOOL ret;

ret = GetPrivateProfileString(Section, Key, "ER_NF", buffer, 2000, INIFN);
if ((ret == 5) & (strcmp(buffer, "ER_NF")==0)) MessageBox(MainhWnd, strcat(er, Key), INIFN, MB_OK|MB_ICONEXCLAMATION );
return(buffer);
}



any help would be greatly appreciated.. Thanks in advance

Illusioned

Lothar Haensler
July 7th, 1999, 02:03 AM
you posted only parts of your code, but the following line looks fishy to me:

if ((ret == 5) & (strcmp(buffer, "ER_NF")==0))



i'd add a second "&" as in

if ((ret == 5) && (strcmp(buffer, "ER_NF")==0))



you are doing a bitwise AND