First is there any thing wrong with this code?
Secondly is there a beter way of writing this code?
Thirdly how would i go about adding books at runtime and
iterate thru the vector to find a specific book?
excuse the english, Thanks in advance
I Never said you should like me.I say be yourself, and make a difference
Hi, I have a dll that runs as a process via dllHost.
My problem is i need to know when a Windows Shutdown event is being fired. I've never had this problem before because all my apps have a main window and receive this notification. However the dll just keeps working and terminates in an undetermined state.
I can't have the dll called from an app. I have no alternative but to use what i've got.
how can i register to receive a WM_SHUTDOWN event from my dll?
Please don't suggest i change the design of the solution. I'm confined to what i have.
thanks for the comment but firstly this needs to be a solution to all current windows platforms (excluding servers) and secondly i'm sure there must be a way to register for this event, even in a dll. hmmm
UINT CheckFileUpdates(LPVOID lp)
hDir, // handle to directory
&Buffer, // read results buffer
sizeof(Buffer), // length of buffer
TRUE, // monitoring option
FILE_NOTIFY_CHANGE_SIZE, // filter conditions
&BytesReturned, // bytes returned
NULL, // overlapped buffer
NULL// completion routine
//do the work
Now on I have abutton on my UI. Onclick of the button I want to stop the above thread.
I I tried to use
while (!GetExitCodeThread(m_UpdateMonitorThread->m_hThread, &dwRetCode));
m_UpdateMonitorThread = NULL;
I am getting memory leaks in both the above cases. I tried to post a Stop Event, but where do I wait for this event inside the thread code as execution will not go inside the while loop code because of ReadDirectoryChangesW.
Can anyone please please suggest a way out to this problem.
Thanks in anticipation of information.
TerminateThread is guaranteed to leak every sort of resources the thread might have acquired. Do not use it ever for finalizing the thread, except in extreme circumstances.
So, try setting a stop event. In order to be able to handle this event while doing the ReadDirectoryChangesW stuff, you must perform the latter in overlapped mode (check the docs for ReadDirectoryChangesW): basically, the op is done asynchronously, and its completion is signalled through an event, so you can fire the operation and wait in one single WaitForMultipleObjects for both completion or the stopping event, whatever comes first.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
if(fileName.CompareNoCase(pView->m_LogFileName) == 0)
//Do the work
But the m_StopEvent event is not caught beacuse the control is stuck at while( ReadDirectoryChangesW) I mean it not going inside the while loop unless ReadDirectoryChangesW returns true. Hence WaitForSingleObject is not checked at all.. Hope you got my point.
Can you please let me know how to write this using OVERLAPPED structure. I never did this before. I am really stuck at this point..unable to proceed further..this is very important for my assignment.
I am building an application; Along with the main SDI window it has a modeless dialog, SDI has system menu but the modeless dialog has no system menu icon; (upper left part of task bar), although I have selected system menu and taskbar options in the dialog properties.
How to add system menu / icon in a modeless dialog?
Add a event handler of WM_TIMER. Create a ID for the particulare timer, ie for 3 minutes say, IDT_TIMER1.
On the initialization part of your application call
Now call the function inside the event handler for WM_TIMER.
Check for the nIDEvent with IDT_TIMER1 if you have multiple timers in your application.
Hope this would help you
The Best Relligion is Science.
Once you understand it, you will know God.