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 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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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");...
|
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,...
|
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
|
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); }...
|
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...
|
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 =...
|
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...
|
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...
|
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...
|
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
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |