<?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[problem beim senden eines &amp;quot;auftrages&amp;quot; an die cmd.exe über writepipe]]></title><description><![CDATA[<p>hi</p>
<p>ich habe eine pipe erzeugt und mit dieser die cmd.exe als childprocess aufgerufen</p>
<p>nun sende ich ihr als reaktion auf einen mausklick folgendes!</p>
<pre><code class="language-cpp">case WM_LBUTTONDOWN:

      WriteFile(newwrite,&quot;regedit\r\n&quot;,9,&amp;bio2,NULL);
</code></pre>
<p>daraufhin sehe ich zwar im taskmanager die regedit.exe, aber auf dem bildschirm noch nicht</p>
<p>wenn ich dann nochmal die mausdrücke erscheint eine regedit doch ich habe dann 2 im taskmanager, ich schließe die erschienene und eine bleibt übrig(niht zu sehen)</p>
<p>beende ich dann mein programm, dann erscheint &quot;endlich&quot; auch die nun zweite regedit</p>
<p>woran könnte das liegen??</p>
<p>muss ich nach writefile noch irgend was machen???</p>
<p>danke + cu</p>
<p>error</p>
<p>ps: befehle wir dir oder auch consolenprogramme wie ping funktionieren sofort(sehe ich, wenn ich die ausgabe auslese)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/134705/problem-beim-senden-eines-quot-auftrages-quot-an-die-cmd-exe-über-writepipe</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 13:23:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/134705.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 27 Jan 2006 20:14:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to problem beim senden eines &amp;quot;auftrages&amp;quot; an die cmd.exe über writepipe on Fri, 27 Jan 2006 20:14:34 GMT]]></title><description><![CDATA[<p>hi</p>
<p>ich habe eine pipe erzeugt und mit dieser die cmd.exe als childprocess aufgerufen</p>
<p>nun sende ich ihr als reaktion auf einen mausklick folgendes!</p>
<pre><code class="language-cpp">case WM_LBUTTONDOWN:

      WriteFile(newwrite,&quot;regedit\r\n&quot;,9,&amp;bio2,NULL);
</code></pre>
<p>daraufhin sehe ich zwar im taskmanager die regedit.exe, aber auf dem bildschirm noch nicht</p>
<p>wenn ich dann nochmal die mausdrücke erscheint eine regedit doch ich habe dann 2 im taskmanager, ich schließe die erschienene und eine bleibt übrig(niht zu sehen)</p>
<p>beende ich dann mein programm, dann erscheint &quot;endlich&quot; auch die nun zweite regedit</p>
<p>woran könnte das liegen??</p>
<p>muss ich nach writefile noch irgend was machen???</p>
<p>danke + cu</p>
<p>error</p>
<p>ps: befehle wir dir oder auch consolenprogramme wie ping funktionieren sofort(sehe ich, wenn ich die ausgabe auslese)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/978446</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/978446</guid><dc:creator><![CDATA[ERROR]]></dc:creator><pubDate>Fri, 27 Jan 2006 20:14:34 GMT</pubDate></item><item><title><![CDATA[Reply to problem beim senden eines &amp;quot;auftrages&amp;quot; an die cmd.exe über writepipe on Thu, 09 Feb 2006 18:36:15 GMT]]></title><description><![CDATA[<p>hi, noch ein versuch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":-)"
      alt="🙂"
    /></p>
<p>ich bekomms nicht hin ... woran könnte es liegen??</p>
<p>hier mal etwas testcode, vielleicht hilfts ja?!:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;process.h&gt;

#define ID_EDIT     1

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

TCHAR szAppName[] = TEXT (&quot;PopPad1&quot;) ;

LPTSTR comandline;
LPTSTR *test;
int *pNumArgs;

unsigned long bio;   //bytes in/out
unsigned long bio2;
unsigned long exitcode=0;
  unsigned long avail;

  static HWND hwndEdit;
  TCHAR buf[10000];           //in buffer
  /*const */TCHAR buffer[6]=&quot;dir\r\n&quot;;           //out buffer
  /*const */TCHAR buffer2[1024];//=&quot;ping zimmer2\r\n&quot;; 

  STARTUPINFO si;
  SECURITY_ATTRIBUTES sa;
  PROCESS_INFORMATION pi;
  HANDLE read, newread, write, newwrite;  //pipe handles

  // Global variable
CRITICAL_SECTION CriticalSection; 

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
  comandline=szCmdLine;

  /*int nArgs;
   comandline=GetCommandLine();
   test = CommandLineToArgvW(comandline, &amp;nArgs);
   if( NULL == test )
   {
      MessageBox (NULL, TEXT (&quot;Fehler&quot;), 
                      szAppName, 0) ;
      return 0;
   }

   comandline+=lstrlen(test[0])+3;

MessageBox (NULL, comandline, 
                      szAppName, 0) ;*/

     HWND     hwnd ;
     MSG      msg ;
     WNDCLASS wndclass ;

     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = NULL ;
     wndclass.lpszClassName = szAppName ;

     if (!RegisterClass (&amp;wndclass))
     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
          MessageBox (NULL, TEXT (&quot;Programm arbeitet mit Unicode und setzt Windows NT voraus!&quot;), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

     hwnd = CreateWindow (szAppName, szAppName,
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          NULL, NULL, hInstance, NULL) ;
     ShowWindow (hwnd, iCmdShow) ;
     UpdateWindow (hwnd) ; 
     InitializeCriticalSection(&amp;CriticalSection);
     while (GetMessage (&amp;msg, NULL, 0, 0))
     {
          TranslateMessage (&amp;msg) ;
          DispatchMessage (&amp;msg) ;
     }
     DeleteCriticalSection(&amp;CriticalSection);

     return (int) msg.wParam ;
}

void ThreadProc(PVOID pParam)
{
  while(true)
  {
    WaitForSingleObject(pi.hProcess,true);

    PeekNamedPipe(newread,buf,10000,NULL,&amp;avail,NULL);

    if(avail!=0)
    {
      RtlZeroMemory(&amp;buf,10000);

      //Hier darf uns nichts zwischen funken!
      EnterCriticalSection(&amp;CriticalSection);

      ReadFile(newread,buf,10000,&amp;bio,NULL);

      SendMessage(hwndEdit,EM_SETSEL,-1,0);
      SendMessage(hwndEdit,EM_REPLACESEL,FALSE,(LPARAM)buf);

      //ok, jetzt kann jemand anderes übernehmen
      LeaveCriticalSection(&amp;CriticalSection);
    }
  }
}

LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  static LRESULT lResult;

  switch(message)
  {//dir funzt sofort, regedit oder ähnliches nicht!??(erst nach erneutem senden) warum
    case WM_RBUTTONDOWN:
          WriteFile(newwrite,&quot;regedit\r\n&quot;,9,&amp;bio2,NULL);
          return 0 ;
    case WM_LBUTTONDOWN://funktioniert ohne probleme
          WriteFile(newwrite,&quot;ping\r\n&quot;,6,&amp;bio2,NULL);
          return 0 ;//statt ping könnte man auch dir oder so machen
    case WM_CREATE :
          hwndEdit = CreateWindow (TEXT (&quot;edit&quot;), NULL, WS_CHILD | WS_VISIBLE  | ES_MULTILINE  | ES_AUTOVSCROLL, 0, 0, 0, 0, hWnd, (HMENU) ID_EDIT,((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ;

          sa.lpSecurityDescriptor = NULL;
          sa.nLength = sizeof(SECURITY_ATTRIBUTES);
          sa.bInheritHandle = true;         //allow inheritable handles

          //Pipe to read from Child
          if(!CreatePipe(&amp;newread,&amp;read,&amp;sa,0))
          {
            MessageBox(hWnd,TEXT(&quot;CreatePipe&quot;),TEXT(&quot;FEHLER&quot;),0);
            CloseHandle(read);
            CloseHandle(newread);
            return -1;
          }

          //Pipe to write to Child
          if(!CreatePipe(&amp;write,&amp;newwrite,&amp;sa,0))
          {
            MessageBox(hWnd,TEXT(&quot;CreatePipe&quot;),TEXT(&quot;FEHLER&quot;),0);
            CloseHandle(write);
            CloseHandle(newwrite);
            return -1;
          }

          si.cb = sizeof(STARTUPINFO);
          GetStartupInfo(&amp;si);      
          si.hStdOutput= read;
          si.hStdError=read;
          si.hStdInput=write;
          si.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
          si.wShowWindow = SW_HIDE;

          //spawn the child process
          if (!CreateProcess(NULL,comandline,NULL,NULL,TRUE,NULL,NULL,NULL,&amp;si,&amp;pi))
          {
            MessageBox(hWnd,TEXT(&quot;CreateProcess&quot;),TEXT(&quot;FEHLER&quot;),0);
            CloseHandle(read);
            CloseHandle(newread);
            CloseHandle(write);
            CloseHandle(newwrite);
            return -1;
          }

          //not needed
          CloseHandle(write);
          CloseHandle(read);

          _beginthread(ThreadProc,0, NULL);
          return 0 ;

     case WM_SETFOCUS :
          SetFocus (hwndEdit) ;
          return 0 ;

     case WM_SIZE : 
          MoveWindow (hwndEdit, 0, 0, 600, 500, TRUE) ;
          return 0 ;

     case WM_DESTROY :
          //clean up some stuff
          TerminateProcess(pi.hProcess,0);

          CloseHandle(newread);
          CloseHandle(newwrite);

          CloseHandle(pi.hThread);
          CloseHandle(pi.hProcess);
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hWnd, message, wParam, lParam) ;
}
</code></pre>
<p>bitte nichts stilistisches beanstanden <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";-)"
      alt="😉"
    /> soll ein reines testprogramm sein!!</p>
<p>das problem tritt bei WM_RBUTTONDOWN auf, rechtsklick irgend wo im rechten bereich des festers...</p>
<p>man sollte, nachdem das prompt nach dem start ausgegeben wurde, alles löschen und zb durch &quot;regedit&quot;</p>
<p>achja, als komandozeilenparameter bitte &quot;cmd&quot;</p>
<p>ich danke für eventuelle mühen</p>
<p>mfg</p>
<p>error</p>
]]></description><link>https://www.c-plusplus.net/forum/post/990344</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/990344</guid><dc:creator><![CDATA[ERROR]]></dc:creator><pubDate>Thu, 09 Feb 2006 18:36:15 GMT</pubDate></item></channel></rss>