|
How big is the file (byte count)? How many bytes did you read? Could you show us some actual code?
--
The Blog: Bits and Pieces
|
|
|
|
|
Kixdemp wrote: ...ReadFile() only reads until line 65 of my file...
ReadFile() has no concept of a line. What exactly are you trying to do?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
How are you calling ReadFile? What are the values of the parameters you pass to ReadFile? What is the value returned in the fourth parameter (lpNumberOfBytesRead)? What is the return value from the call to ReadFile?
I am willing to bet that the buffer you are reading into (second parameter) is uninitialized, and the third parameter (nNumberOfBytesToRead) is smaller than the size of your file and/or not the same size as the buffer.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks all for your replies!
Bytes in file: 4,970
Code:
<br />
HANDLE bipFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, <br />
FILE_ATTRIBUTE_NORMAL, NULL);<br />
<br />
if (bipFile == NULL)<br />
{<br />
throw 1;<br />
}<br />
<br />
DWORD dwNumRead;<br />
<br />
char * dwBuffer = new char[1024^4];<br />
<br />
if (!ReadFile(bipFile, dwBuffer, 1024^4, &dwNumRead,NULL))<br />
throw 2;<br />
<br />
CloseHandle(bipFile);<br />
What's wrong with that? Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
|
Three things:
CreateFile() returns INVALID_HANDLE_VALUE on error, not NULL .
1024^4 does not mean "1024 to the forth power."
Why are you trying to allocate that much memory in the first place? It will never succeed.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
-- modified at 22:12 Sunday 27th November, 2005
|
|
|
|
|
Hello,
The problem is that your buffer is too small. Just as Micheal Dunn pointed out: 1024^4 doesn't do what you want. operator ^ is the XOR operator. The result is: 1028.
You should try the following:
char pcBuf[1024] = {0};
DWORD dwBytesRead = 0;
while( !ReadFile(bipFile, pcBuffer, 1024, &dwBytesRead, NULL )
{
if( dwBytesRead < 1024 )
break;
}
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Just FYI, flushing is only meaningful when writing to a file. If you're just reading, there's nothing to flush.
Calling Flush() probably had some other side effect (resetting the file pointer or something) that made your code appear to work.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
"Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"
-- Rico Mariani, CLR perf guy
|
|
|
|
|
Thanks all! I'll take your advices!
But... I always thought ^ was exponent... And, is 102400 a lot? 102.4 KB... And I do it because one never knows how much bytes a file has... or is there a way to know?
Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
^ is often used in a text environment (like message boards) to mean exponent, however in C it means bitwise XOR.
10244 = 1099511627776, or 1.1 trillion bytes.
You can call GetFileSize() to get the length.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
"Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"
-- Rico Mariani, CLR perf guy
|
|
|
|
|
|
|
|
the function
CWebBrowser2::Navigate(url)
displays an error message-box if url doesn't exist.
is there any idea to avoid (or do not display) the message-box?
includeh10
|
|
|
|
|
|
what is the use of the CImageIterator
|
|
|
|
|
Having absolutely no clue about what you're actually talking about, since you provide zero context to a complete non-question, I'd give this sound guess:
An abstrcation of iteration through the pixels of an image.
--
The Blog: Bits and Pieces
-- modified at 5:34 Sunday 27th November, 2005
|
|
|
|
|
I am sorry,I can't use English well.My mean is that there is a CImageIterator class in CxImage, and what's use of this class?
|
|
|
|
|
Then my initial guess was correct. I've used CxImage extensively and know for a fact that CImageIterator iterates the pixels of a CxImage .
--
The Blog: Bits and Pieces
|
|
|
|
|
Thank you for your answer.. I have another question that how to display a gif picture by CxImage?
blackeye
|
|
|
|
|
I often get "error LNK2001: unresolved external symbol" for _FunctionName@24,
what is this supposed to mean?
what does this notation _FunctionName@24 mean?
thanks!
|
|
|
|
|
Different compilers/vendors 'decorate' functions names with various schemes when they compile your code into object modules - this is commonly known as 'mangling'
In MSVC for example, its possible to decode the function name AND its parameters from looking at a mangled name. There is also, to make things worse, a difference in 'c' vs c++ name generation ...
That you get a LNK2001 error should be obvious - you have a call to that 'FunctionName' in your code and it cant be found in an object module's symbol/export table - maybe you're not linking against the right object/DLL or such
There are plenty of articles out there detailing how to fix this along with stdcall, cdecl discussions (search to find what I mean), I'm probably not the best person to give you a more in-depth reply than this ..
'g'
|
|
|
|
|
assume there is a link
<a href="file://c:/abc/xxx">
how to know if the file exists?
the link may not be a file, i.e.
xxx=open?param
or something else.
includeh10
-- modified at 23:53 Saturday 26th November, 2005
|
|
|
|
|
|
Can I program TAPI to detect CLI tones instead of DTMF tones?
Thanks for reading.
Vaclav
|
|
|
|