|
pDoc != NULL and the struct is public. Anyother possible problems?
-Raffi
|
|
|
|
|
Stop just before the offending line and inspect the contents of pDoc . Does it look OK (reasonable data)?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How do I see the contents of pDoc?
-Raffi
|
|
|
|
|
Insert a breakpoint at the offending line (F9), run the program, wait till it stops at your breakpoint, press SHIFT+F9 (I think) and type pDoc in the window that appears.
If you need more help about using the debuger, have a look at the documentation that comes with your VC++ --it shouldn't be hard to locate the section on debugging.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It says pDoc is 0x00781ca0. Dose that look "OK"?
-Raffi
|
|
|
|
|
Man, use your brain. Inspect the contents of pDoc .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
[quote]It says pDoc is 0x00781ca0. Dose that look "OK"? [/quote]
this is the memory location only!
|
|
|
|
|
Hi,
Im doing a small program in which I want to detect if the internet is being accessed by the user.
I have searched for this but with no luck
|
|
|
|
|
This article shows how to check if you're connected to the internet.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
OK. I'm trying to open a file and red the last 128 bytes in it, but if it's the first time i read the file since the computer has been started, it only reads the first three chars. It's strange cause when i then open it right after i have opened it the first time, it works. here's the code:
int GetID3(char *szFile)
{
HANDLE hFile;
DWORD dwBytesRead;
DWORD dwFileSize;
OVERLAPPED FilePos;
OVERLAPPED *pFilePos = &FilePos;
hFile = CreateFile (szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
dwFileSize = GetFileSize(hFile, NULL);
pFilePos->Offset = dwFileSize - 128;
pFilePos->OffsetHigh = 0;
pFilePos->hEvent = 0;
gszID3Tag[0] = '\0';
ReadFile(hFile, gszID3Tag, 128, &dwBytesRead, pFilePos);
gszID3Tag[128] = '\0';
if (dwBytesRead != 128)
return 0;
else
return 1;
}
Can anyone help me?
Thankyou.
|
|
|
|
|
Since you're reading the file in overlapped mode, it is perfectly possible that the reading operation has not completed when ReadFile returns. Try inserting a Sleep(1000) right after ReadFile (of course this is not the way to fix the problem, but it can help you to determine its cause.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is there any particular reason why you are using overlapped IO? With the simple function that you have posted, it does not seem to be necessary. Also you should be calling CloseHandle on hFile when you are done with the file handle, this function is leaving the file open.
With overlapped IO, the ReadFile function becomes asynchronous and the function may not be done reading the file when you move on to the next statements in your function rather than in normal mode the function does not continue until all of the data that you requested has been read from the file. If the function is not yet done it will return a ERROR_IO_PENDING value indicating that it is not yet done.
Since your file is left open, the data is probaly stored in the file cache and the next time you go to read from that file, it automatically has the data to place into your buffer and that is why it is available.
My suggestion, if you can avoid the overlapped IO, I would do it.
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
The reason iøm using the overlapped structure, is because i can specify a file offset, 128 bytes from the end of the file, is there another way to do this?
|
|
|
|
|
<a href="http://msdn.microsoft.com/library/en-us/fileio/filesio_8iwi.asp">SetFilePointer</a> .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Oh, thankyou, works perfectly
|
|
|
|
|
I would like to add one more thing, when you do overlapped IO, you are responsible for keeping track of the file pointer and other things. When you do normal, or synchronous IO, the file pointer is stored with the HANDLE, or hFile that you create. AFter you read from a file the file pointer will automatically be updated to the end of where you read the data with normal IO, as opposed to you having to update the pointer yourself.
Good Luck.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I'll just add that if you read this file using an ifstream you'd probably find the code a lot simpler as well as safer.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Thankyou )
|
|
|
|
|
use classwizard. find your dialog item, add a handler for BN_CLICKED.
then use CButton::GetCheck to test the checked state
-c
There ain't no second chance
Against the thing with the forty eyes, girl
|
|
|
|
|
But eh thing is i'm not using MFC. I know that i should look for the WM_COMMAND code in the uMsg parameter and the control name IDC_ID3TAG in the wParam, but i don't know how to find out if it's checked or not.
|
|
|
|
|
Here's how:
long nResult = SendMessage (hwndCheckBox, BM_GETCHECK, 0, 0);
bool bChecked = (nResult == BST_CHECKED); /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi!
Is there a better way to check whether the data in a clipboard has changed instead of checking the content every few seconds with a timer? Perhaps there is a kind of notification?
/edit: I just found the message WM_DRAWCLIPBOARD - is it what I'm searching for?
thanks in advance
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
From MSDN:
The WM_DRAWCLIPBOARD message is sent to the first window in the clipboard viewer chain when the content of the clipboard changes. This enables a clipboard viewer window to display the new content of the clipboard.
|
|
|
|
|
how can i be able to display my custom Context Menu when i right-clicked in an EditBox instead of default EditBox context menu (Undo, copy, paste..etc)?
that would be really helpful for me...
Thanks for ur help
Atilla Selem
just listening to you...
|
|
|
|
|
try the edit control section of this site...
or... http://www.codeproject.com/useritems/cmenuedit.asp
-c
I don't care, and you can't make me.
|
|
|
|