473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

ReadFile Problem

Im trying to make it so I can read something out of a file and get it
into a string so I can see if It matches what IM looking for.

Here is what I got:

HANDLE hFile;
DWORD wmWritten;
char strVal[1024];
hFile =
CreateFile("settings.ini",GENERIC_READ|GENERIC_WRI TE,

0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

if(ReadFile(hFile,strVal,1024,&wmWritten,NULL) ==
"ontop=1"){
AppendMenu(hSubMenu, MF_STRING|MF_CHECKED, TOP,
"&Always On Top");
}
else if(ReadFile(hFile,strVal,1024,&wmWritten,NULL) ==
"ontop=0"){
AppendMenu(hSubMenu, MF_STRING|MF_UNCHECKED, TOP,
"&Always On Top");
}
else{
AppendMenu(hSubMenu, MF_STRING|MF_CHECKED, TOP,
"&Always On Top");
}

I got this: "error: ISO C++ forbids comparison between pointer and
integer"
I am useing Code::Blocks v1.0

Please Help

May 21 '06 #1
2 2439
Spacetech wrote:
Im trying to make it so I can read something out of a file and get it
into a string so I can see if It matches what IM looking for.

Here is what I got:

HANDLE hFile;
DWORD wmWritten;
char strVal[1024];
hFile =
CreateFile("settings.ini",GENERIC_READ|GENERIC_WRI TE,

0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

if(ReadFile(hFile,strVal,1024,&wmWritten,NULL) ==
"ontop=1"){ i think this should be the problem. The return value of ReadFile can't
compare with a string "ontop" AppendMenu(hSubMenu, MF_STRING|MF_CHECKED, TOP,
"&Always On Top");
}
else if(ReadFile(hFile,strVal,1024,&wmWritten,NULL) ==
"ontop=0"){
AppendMenu(hSubMenu, MF_STRING|MF_UNCHECKED, TOP,
"&Always On Top");
}
else{
AppendMenu(hSubMenu, MF_STRING|MF_CHECKED, TOP,
"&Always On Top");
}

I got this: "error: ISO C++ forbids comparison between pointer and
integer"
I am useing Code::Blocks v1.0

Please Help

May 21 '06 #2
Spacetech wrote:
Im trying to make it so I can read something out of a file and get it
into a string so I can see if It matches what IM looking for.
You are using Windows specific features which are off-topic in this
newsgroup. Either switch to standard constructs (std::ifstream,
std::string and std::getline) or ask elsewhere
(http://www.parashift.com/c++-faq-lit....html#faq-5.9).
Here is what I got:

if(ReadFile(hFile,strVal,1024,&wmWritten,NULL) ==
"ontop=1"){ I got this: "error: ISO C++ forbids comparison between pointer and
integer"


Looks like the function ReadFile() returns an integer and that you are
comparing it with "ontop=1", which is a pointer (const char*). Check
the documentation on this function.
Jonathan

May 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: deko | last post by:
I need to allow users to download files from a directory that is not publicly accessible. To do this, I use a download script: header("Content-Type: application/octet-stream");...
0
by: Mustafa Ahmad Malik | last post by:
Hello, I have wrapped the Win32 pipes function in C#. I have created named pipe with PIPE_WAIT in pipemode parameter like this pipehandle = CreateNamedPipe(_pipeName, PIPE_ACCESS_DUPLEX,...
12
by: ORC | last post by:
Shouldn't 'ReadFile' block when timeouts are specified even when running in overlapped mode or am I wrong ??? Thanks Ole
2
by: GTi | last post by:
StringBuilder text = new StringBuilder(lpNextSize+1, lpNextSize+1); int pNumberOfBytesRead = text.Capacity; try { result=win32.ReadFile(_Handle, text, text.Capacity, ref pNumberOfBytesRead, 0); }...
2
by: Schorschi | last post by:
Can't seemd to get ReadFile API to work! Returns invalid handle error? =========================================================================== Ok, the visual basic gurus, help! The...
0
friendjin
by: friendjin | last post by:
WriteFile(hCom1, "AT+CSQ\r", sizeof("AT+CSQ\r"), &dwWritten, &ovlw); Sleep(50); COMMTIMEOUTS comto; comto.ReadIntervalTimeout = 10; comto.ReadTotalTimeoutMultiplier =...
4
by: Eric Renken | last post by:
I am trying to do an Overlapped ReadFile on a HID device and it just isn't working for me. The WaitForSingleObject keeps giving me an error "The system cannot find the file specified." This...
1
by: mkarja | last post by:
Hi, I have a windows MDI program that draws some shapes that can be saved into a file and read from that file. The save seems to work with the WriteFile function, but for some reason the...
15
by: Ketchup | last post by:
Hello everyone, I have been stuck with this problem for quite some time now. I am working in VB.NET, using framework 1.0. I have to keep the compatibility down to the original .NET framework...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.