<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CreatePipe schreiben]]></title><description><![CDATA[<p>Hallo! Ich habe eine Frage zum umleiten der standardausgabe und standardeingabe.<br />
Hier habe ich ein Beispiel gefunden wo von stdout gelesen wird:</p>
<pre><code class="language-cpp">CString ExecuteExternalFile(CString csExeName, CString csArguments)
{
  CString csExecute;
  csExecute=csExeName + &quot; &quot; + csArguments;

  SECURITY_ATTRIBUTES secattr; 
  ZeroMemory(&amp;secattr,sizeof(secattr));
  secattr.nLength = sizeof(secattr);
  secattr.bInheritHandle = TRUE;

  HANDLE rPipe, wPipe;

  //Create pipes to write and read data

  CreatePipe(&amp;rPipe,&amp;wPipe,&amp;secattr,0);
  //

  STARTUPINFO sInfo; 
  ZeroMemory(&amp;sInfo,sizeof(sInfo));
  PROCESS_INFORMATION pInfo; 
  ZeroMemory(&amp;pInfo,sizeof(pInfo));
  sInfo.cb=sizeof(sInfo);
  sInfo.dwFlags=STARTF_USESTDHANDLES;
  sInfo.hStdInput=NULL; 
  sInfo.hStdOutput=wPipe; 
  sInfo.hStdError=wPipe;
  char command[1024]; strcpy(command,  
          csExecute.GetBuffer(csExecute.GetLength()));

  //Create the process here.

  CreateProcess(0 command,0,0,TRUE,
          NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&amp;sInfo,&amp;pInfo);
  CloseHandle(wPipe);

  //now read the output pipe here.

  char buf[100];
  DWORD reDword; 
  CString m_csOutput,csTemp;
  BOOL res;
  do
  {
                  res=::ReadFile(rPipe,buf,100,&amp;reDword,0);
                  csTemp=buf;
                  m_csOutput+=csTemp.Left(reDword);
  }while(res);

  return m_csOutput;
}
</code></pre>
<p>Ich habe versucht mit WriteFile auf rPipe und wPipe zu schreiben, hat aber nicht geklappt. Hat einer eine Idee wie man es realisieren kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/223722/createpipe-schreiben</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 02:00:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/223722.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Sep 2008 09:46:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CreatePipe schreiben on Tue, 30 Sep 2008 09:46:42 GMT]]></title><description><![CDATA[<p>Hallo! Ich habe eine Frage zum umleiten der standardausgabe und standardeingabe.<br />
Hier habe ich ein Beispiel gefunden wo von stdout gelesen wird:</p>
<pre><code class="language-cpp">CString ExecuteExternalFile(CString csExeName, CString csArguments)
{
  CString csExecute;
  csExecute=csExeName + &quot; &quot; + csArguments;

  SECURITY_ATTRIBUTES secattr; 
  ZeroMemory(&amp;secattr,sizeof(secattr));
  secattr.nLength = sizeof(secattr);
  secattr.bInheritHandle = TRUE;

  HANDLE rPipe, wPipe;

  //Create pipes to write and read data

  CreatePipe(&amp;rPipe,&amp;wPipe,&amp;secattr,0);
  //

  STARTUPINFO sInfo; 
  ZeroMemory(&amp;sInfo,sizeof(sInfo));
  PROCESS_INFORMATION pInfo; 
  ZeroMemory(&amp;pInfo,sizeof(pInfo));
  sInfo.cb=sizeof(sInfo);
  sInfo.dwFlags=STARTF_USESTDHANDLES;
  sInfo.hStdInput=NULL; 
  sInfo.hStdOutput=wPipe; 
  sInfo.hStdError=wPipe;
  char command[1024]; strcpy(command,  
          csExecute.GetBuffer(csExecute.GetLength()));

  //Create the process here.

  CreateProcess(0 command,0,0,TRUE,
          NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&amp;sInfo,&amp;pInfo);
  CloseHandle(wPipe);

  //now read the output pipe here.

  char buf[100];
  DWORD reDword; 
  CString m_csOutput,csTemp;
  BOOL res;
  do
  {
                  res=::ReadFile(rPipe,buf,100,&amp;reDword,0);
                  csTemp=buf;
                  m_csOutput+=csTemp.Left(reDword);
  }while(res);

  return m_csOutput;
}
</code></pre>
<p>Ich habe versucht mit WriteFile auf rPipe und wPipe zu schreiben, hat aber nicht geklappt. Hat einer eine Idee wie man es realisieren kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1590762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1590762</guid><dc:creator><![CDATA[neoexpert]]></dc:creator><pubDate>Tue, 30 Sep 2008 09:46:42 GMT</pubDate></item><item><title><![CDATA[Reply to CreatePipe schreiben on Tue, 30 Sep 2008 10:28:54 GMT]]></title><description><![CDATA[<p>Wo willst Du denn bite auf die Pipe schreiben? Der Prozess schreibt in die etsprechende offene Pipe und Du liest aus ihr. Wo ist hier in diesem Code das Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1590781</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1590781</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 30 Sep 2008 10:28:54 GMT</pubDate></item><item><title><![CDATA[Reply to CreatePipe schreiben on Tue, 30 Sep 2008 11:34:23 GMT]]></title><description><![CDATA[<p>Mit dem Code gibt es kein Problem. Ich möchte den code so verändern, dass man in das ausgeführte programm auch was schreiben kann. Braucht man da noch eine Pipe?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1590816</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1590816</guid><dc:creator><![CDATA[neoexpert]]></dc:creator><pubDate>Tue, 30 Sep 2008 11:34:23 GMT</pubDate></item><item><title><![CDATA[Reply to CreatePipe schreiben on Tue, 30 Sep 2008 11:39:01 GMT]]></title><description><![CDATA[<p>Wenn Du damit meinst, dass das Programm etwas über stdin bekommen soll, müsstest Du auch stdin manipulieren!<br />
stdout und stderr haben damit ja nichts zu tun.</p>
<p>Schau Dir mal ein komplettes Beispiel an:<br />
<a href="http://support.microsoft.com/kb/190351" rel="nofollow">http://support.microsoft.com/kb/190351</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1590822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1590822</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 30 Sep 2008 11:39:01 GMT</pubDate></item><item><title><![CDATA[Reply to CreatePipe schreiben on Tue, 30 Sep 2008 12:07:51 GMT]]></title><description><![CDATA[<p>Dieses Beispiel habe ich schon gesehen, ich finde ihn zu lang, muss man da nicht einfach 2 Pipes erzeugen, eine zum lesen und eine zum schreiben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1590843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1590843</guid><dc:creator><![CDATA[neoexpert]]></dc:creator><pubDate>Tue, 30 Sep 2008 12:07:51 GMT</pubDate></item><item><title><![CDATA[Reply to CreatePipe schreiben on Tue, 30 Sep 2008 13:18:14 GMT]]></title><description><![CDATA[<p>neoexpert schrieb:</p>
<blockquote>
<p>Dieses Beispiel habe ich schon gesehen, ich finde ihn zu lang, muss man da nicht einfach 2 Pipes erzeugen, eine zum lesen und eine zum schreiben?</p>
</blockquote>
<p>Wie lang darf ein Sample sein um ein problem zu lösen?<br />
Ja Du musst auch eine Pipe für StdIn definieren!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1590876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1590876</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 30 Sep 2008 13:18:14 GMT</pubDate></item><item><title><![CDATA[Reply to CreatePipe schreiben on Tue, 30 Sep 2008 13:45:44 GMT]]></title><description><![CDATA[<p>ja<br />
und wenn ich ein anderes Handle als NULL dem sInfo.hStdInput zuweise, dann kann ich nicht von stdout lesen<br />
hier mein aktueller code.<br />
Es soll &quot;cmd.exe&quot; geöffnet werden und ein &quot;dir\n&quot; an das Program gesendet werden<br />
was mache ich denn falsch?</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
#include &lt;vcl.h&gt;
#include &lt;windows.h&gt;
#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
        SECURITY_ATTRIBUTES secattr;
        ZeroMemory(&amp;secattr,sizeof(secattr));
        secattr.nLength = sizeof(secattr);
        secattr.bInheritHandle = TRUE;

        HANDLE rPipe, wPipe;
        HANDLE rPipe2, wPipe2;

        //Create pipes to write and read data

        CreatePipe(&amp;rPipe,      &amp;wPipe, &amp;secattr,0);
        CreatePipe(&amp;rPipe2,     &amp;wPipe2,&amp;secattr,0);
        //

        STARTUPINFO sInfo;
        ZeroMemory(&amp;sInfo,sizeof(sInfo));
        PROCESS_INFORMATION pInfo;
        ZeroMemory(&amp;pInfo,sizeof(pInfo));
        sInfo.cb=sizeof(sInfo);
        sInfo.dwFlags=STARTF_USESTDHANDLES;
        sInfo.hStdInput=rPipe2;
        sInfo.hStdOutput=wPipe;
        sInfo.hStdError=wPipe;

        //Create the process here.

        CreateProcess(0, &quot;cmd.exe&quot;,0,0,TRUE,
        NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&amp;sInfo,&amp;pInfo);

        CloseHandle(wPipe);
        //now read the output pipe here.

        char buf[100];
        DWORD reDword;
        AnsiString m_csOutput,csTemp;
        BOOL res;
        do
        {
                res=::ReadFile(rPipe,buf,100,&amp;reDword,0);
                buf[reDword]='\0';
                csTemp=buf;
                m_csOutput+=csTemp;
        }while(res);
        ShowMessage(m_csOutput);
        WriteFile(wPipe2,&quot;dir\n&quot;,strlen(&quot;dir\n&quot;),NULL,NULL);
        do
        {
                res=::ReadFile(rPipe,buf,100,&amp;reDword,0);
                buf[reDword]='\0';
                csTemp=buf;
                m_csOutput+=csTemp;
        }while(res);
        ShowMessage(m_csOutput);
        return 0;
}
//---------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1590888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1590888</guid><dc:creator><![CDATA[neoexpert]]></dc:creator><pubDate>Tue, 30 Sep 2008 13:45:44 GMT</pubDate></item><item><title><![CDATA[Reply to CreatePipe schreiben on Tue, 30 Sep 2008 15:47:50 GMT]]></title><description><![CDATA[<p>Es ist nicht gesagt, dass die EXE <a href="http://STD.IN" rel="nofollow">STD.IN</a> so zweilenweise liest wie Du es erwartest. Evtl. bekommt die ja schon EOF und terminiert.</p>
<p>Was hast Du denn mit dieser Umleitung auf CMD.EXE vor?<br />
Schreib doch einen Batch, das ist doch weitaus einfacher.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1591003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1591003</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 30 Sep 2008 15:47:50 GMT</pubDate></item></channel></rss>