Home > Back-end >  When creating anonymous pipe for CMD return information questions? Daniel answered rookie
When creating anonymous pipe for CMD return information questions? Daniel answered rookie

Time:10-16

Programming wrote a CMD to return information, because the return information is very short so think read only read the data in a pipe is, later found it easy to do wrong,
Ipc connection, for example, using the wrong user name password when connecting return
////////////////////////
System error 1326,

Logon failure: unknown user name or incorrect password,
/////////////////////////
The key code below middle slightly omit
While (true)
{
.
Memset (buffer, 0256);//here under a breakpoint: breakpoint 1
ReadFile (hRead, buffer, 256, & amp; BytesRead, NULL);
Printf (" % s ", buffer);
.
}
F5 to debug the breakpoint 1 stop every time, just wait for moment F5 can get normal value, the following
System error + buffer 0 x0037f378 "1326, \ r \ n \ r \ n logon failure: unknown user name or bad password, \ r \ n \ r \ n" char [256]
This is normal situation (directly copied from vs2012 debugging)
But if remove the breakpoint, run directly each time the data read from the pipe becomes the following
System error 1326 + buffer 0 x0014f190 ", \ r \ n "char [256]
Can only read part of
Now I change the program to the following form
//////////////////////////////////////////////
Char buffer [256]={0};
String strOutput="";
DWORD bytesRead;
While (true)
{
Memset (buffer, 0256);
If (ReadFile (hRead, buffer, 256, & amp; BytesRead, NULL)==NULL)//read line
break;
StrOutput +=buffer;
}
////////////////////////////////////////////
Now you want to ask, why will appear this kind of can only read some data of the phenomenon? Problems setting up the pipeline or the program logic which have problems? Ask and answer

CodePudding user response:

I don't know master advice?
  • Related