|
I believe WaitForSingleObject() will wait until what you're waiting on is signaled or returns.
I use WaitForSingleObject() when I want to wait for either a thread or a process to terminate, before doing what I want to do, or for an event to get signaled. As such, what you are doing will probably wait for the process to terminate. If you want to wait for an event within that process, you will have to do something more complicated.
|
|
|
|
|
Problem solved:
if (CreateProcess( lpAppPath,
strCommandLine,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
NULL,
&processInformation
)
)
{
DWORD dw = MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE, QS_POSTMESSAGE|QS_SENDMESSAGE );
}
else
{
AfxMessageBox(L"The process could not be started...");
}
MsgWaitForMultipleObjects(...)
As the documentation says:
Use caution when calling the wait functions and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. A thread that uses a wait function with no time-out interval may cause the system to become deadlocked. For example, the Dynamic Data Exchange (DDE) protocol and the COM function CoInitialize both indirectly create windows that can cause a deadlock. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx , rather than WaitForSingleObject .
|
|
|
|
|
On my OS regional setting is Chinese(PRC).
I hav a MFC dialog. One of the control is of ControlType "CEdit". This control is restricted to take numeric inputs (ES_NUMBER) only and that too of 2 digits (using SetLimitText(2)) only.
While running the application, when I enter a single digit it automatically gets twice. For instance if I enter 5 it gets converted to 55 and so on... So in that case I cannot enter 2 digits as max limit of the control is set to 2.
Plz help...
Thanks in advance...
Regards
SG div>
|
|
|
|
|
Do you have an EN_CHANGE handler?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I want to write a program and I need to see that is a certain program running or not , how can I do that ?
thanks
|
|
|
|
|
If the program is service, you can find with IsServiceRunning API.
If it is Window/Dialog Exe, you can do it with FindWindowEx API. Read how to use FindWindowEx API.
|
|
|
|
|
|
Be careful when using FindWindowEx() . It has the potential to cause a deadlock situation.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think its good advise about FindWindow.;)
|
|
|
|
|
When i close a dialog bar using close button on dialogbar which messages get generated as i wanna resize other windows and their child controls .
Please help urgent...
do i have to override RecalcLayout function of main frame.
Thanks,
Sandip.
|
|
|
|
|
SandipG wrote: When i close a dialog bar using close button on dialogbar which messages get generated
WM_SYSCOMMAND?
This episode brought to you by the number 5
|
|
|
|
|
Hi,
I'm coding a treeview which resembles with the one in Windows Explorer.
Initially root item is Desktop and it's IShellFolder interface can be easily
retrived using SHGetDesktopFolder() function.
Can any one tell me how to get IShellFolder interface to any folder? e.g. "C:\"
Regards,
Abhijeet
---
Never look back...
|
|
|
|
|
|
This class must contain a function which return the position when it was made a change of bytes. For example if in char I have 0 0 0 1 0, the function must to return 4. If I have 0 0 0 0 0 0 1 1 1 1, the function must to return 6. Bytes are loaded from a file.txt. I want a solution, if it possible in next 2 days.
Thanks,
nickalai
|
|
|
|
|
nickalai17 wrote: I want a solution, if it possible in next 2 days.
are you asking us to do your homework ?
that's not gonna happen.
|
|
|
|
|
Your homework is due in 2 days ? Better get started, instead of trying to find someone to do it for you online. If you get stuck, you can ask us specific questions, of course.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How would you do this on paper?
1) Read the first byte, and store it in a variable.
2) Read next byte.
3) If it matches the first byte, increment counter. Go to 2.
4) If it doesn't match the first byte, stop.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm curious why
0 0 0 1 0
should return 4, but
0 0 0 0 0 0 1 1 1 1
should return 6...
Good luck with that
This episode brought to you by the number 5
|
|
|
|
|
How do I create a virtual serial port (e.g. COM9)?
Is building a kernel mode device driver the only way or can I create something in user mode that my applications can open and interact with as if it was a standard serial port?
Thanks
Alec
|
|
|
|
|
There are a lot of open source virtual serial port implementation, just do a google search.
|
|
|
|
|
|
I want to display a dialog in a MDI application whenever there are no more documents(or dialogs) open.
Is there a message that i can intercept when everything is closed?
|
|
|
|
|
You can enumerate the number of child frames open at any give time by using EnumChildWindows. In your particular case, you can check on close of child window (the message is WM_CLOSE) that how many windows are open. If they are 0, u can show the dialog.
"Some people believe football is a matter of life and death.
I'm very disappointed with that attitude.
I can assure you it is much, much more important than that. -- Bill Shankly"
|
|
|
|
|
|
Hi everyone,
I am using
AfxGetApp()->m_pDocManager->OnFileNew();
to generate a new file. I want to change the properties of activex control embedded in the window that i am creating, so in this case how do i get a pointer to the axtive control variable which i have defined in view class. Or can anyone suggest how to get a pointer to the window that i create through above function.
|
|
|
|