IF-ELSE problems. Why?
I have this code:
But even when my ini file contains the text "foo" the program still returns my if-else statment as false. Why is it doing this? The method works fine in DOS programming.
hFile=CreateFile("Settings.ini", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
ReadFile(hFile, Buffer, 3, &dwBytes, NULL);
You can compare strings like that.... try lstrcmp :)
You should also be checking the return values from CreateFile and ReadFile to ensure they are working as expected.
I dont get it. What do you mean by "try lstrcmp"? In what way?
It's a winapi variant of strcmp - see lstrcmp.
It doesn't seem to be working, could you give me an example?
Traditionally, one posts troublesome code and requests advice on that. ;)
Note the lstrcmp is case sensitive; if you want case insensitivity then use lstrcmpi.
/*strings not the same*/
I tried that but it doesn't matter what the text is it always returns as true.:(
Oops... Sorry, I declared Buffer twice, over writeing what ReadFile picked up.
Thanks for showing me how to do it Ken. :)