Hi All,
[Application & code back ground] I have an MFC application which is executing on Windows Server 2008 R2 in WOW64 environment. In which on user input it defragments the selected drive on the disk. I initiated the process(.i.e. cmd /c defrag –v c: ) of defragmentation using the CreateProcess() API, along with this to display output of the process on the main screen I created the pipe using CreatePipe() API. I used PeekNamedPipe() & ReadFile() API to get the output and display.
[Problem Area] When the process is launched I am not getting the initial output as below:
Invoking defragmentation on (C: )….
I constantly monitor the output of the process while it is under progress but not able to get any thing as output in the pipe. It seem the process is not doing any thing and appears as if the application is not responding. But after certain period of time, once the process is about to completed I get result along with the initial data.
[Sample code]
if
(MFALSE == ::ReadFile(m_hStdOutRead, l_cArrOutput, min(BUFFER_SIZE -
2
, l_dwAvailable), &l_dwRead, NULL) || !l_dwRead) {
Same code work fine on windows xp
If any one is aware of similar problem or worked on the similar issue please let me know the solution.
BytesAvail = 0
PeekNamedPipe hReadPipe, ByVal 0&, 0, ByVal 0&, BytesAvail, ByVal 0&
If BytesAvail = 0 Then Exit Function
'BytesAvail is allways 0 :thumbsdown:
' Corected with this Code:
BytesAvail = 0
PeekNamedPipe hReadPipe, ByVal 0&, 0, ByVal 0&, BytesAvail, ByVal 0&
WaitForSingleObject hproc, 1
'
If BytesAvail = 0 Then Exit Function
' This is working !!!!!!!!!!!! :) :thumbsup:
' BytesAvail is populated after call to PeekNamedPipe
' Branko Geci *REMOVED MAIL*
Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad
spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or
edit the question
and fix the problem. Insults are not welcome.
Don't tell someone to read the manual. Chances are they have and don't get it.
Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.