Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Redirect another process' output to a stream

Redirect another process' output to a stream

Scheduled Pinned Locked Moved Mobile
csharpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chaser92
    wrote on last edited by
    #1

    Hello, my application needs to redirect a process' output to a stream, just like Win32's .NET did via StartInfo.RedirectOutputStream, but this function is missing in CF. Is there another way (maybe via P/Invoke?) Greetings

    L 1 Reply Last reply
    0
    • C Chaser92

      Hello, my application needs to redirect a process' output to a stream, just like Win32's .NET did via StartInfo.RedirectOutputStream, but this function is missing in CF. Is there another way (maybe via P/Invoke?) Greetings

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You seem to be searching for a managed method for accomplishing your goal. Unfortunately I don't know if there is other managed ways to redirect standard I/O. What I can tell you is that the unmanaged Win32 API that redirects standard devices is the SetStdHandle Function[^]. Good Luck, -David Delaune

      C 1 Reply Last reply
      0
      • L Lost User

        You seem to be searching for a managed method for accomplishing your goal. Unfortunately I don't know if there is other managed ways to redirect standard I/O. What I can tell you is that the unmanaged Win32 API that redirects standard devices is the SetStdHandle Function[^]. Good Luck, -David Delaune

        C Offline
        C Offline
        Chaser92
        wrote on last edited by
        #3

        Which library contains the procedure in WinCE? this example seems to work only for Win32

        L 1 Reply Last reply
        0
        • C Chaser92

          Which library contains the procedure in WinCE? this example seems to work only for Win32

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Chaser92 wrote:

          Which library contains the procedure in WinCE?

          You have my apologies. I did not realize that you were asking about an embedded environment. Perhaps you are looking for SetStdioPathW[^] and GetStdioPathW[^]? You can possibly use CreatePipe to create alternate input/output handles which are also opened from inside your application giving you complete input/output control. I think it could work like this: 1.) Call CreatePipe and save the handle to newhandle variable. 2.) Spawn a thread which reads the pipe handle. 3.) Call GetStdioPathW and save the handle to the a saved_output_handle variable. 4.) Call SetStdioPathW(1,newhandle). 5.) Call CreateProcess and your child process will inherit the parent i/o handles. 6.) Call SetStdioPathW(1,saved_output_handle) so you restore your own standard io handle. I hope I made sense... if not just ask. Best Wishes, -David Delaune

          C 1 Reply Last reply
          0
          • L Lost User

            Chaser92 wrote:

            Which library contains the procedure in WinCE?

            You have my apologies. I did not realize that you were asking about an embedded environment. Perhaps you are looking for SetStdioPathW[^] and GetStdioPathW[^]? You can possibly use CreatePipe to create alternate input/output handles which are also opened from inside your application giving you complete input/output control. I think it could work like this: 1.) Call CreatePipe and save the handle to newhandle variable. 2.) Spawn a thread which reads the pipe handle. 3.) Call GetStdioPathW and save the handle to the a saved_output_handle variable. 4.) Call SetStdioPathW(1,newhandle). 5.) Call CreateProcess and your child process will inherit the parent i/o handles. 6.) Call SetStdioPathW(1,saved_output_handle) so you restore your own standard io handle. I hope I made sense... if not just ask. Best Wishes, -David Delaune

            C Offline
            C Offline
            Chaser92
            wrote on last edited by
            #5

            I get it, but as I don't know much about unmanaged coding, could you tell me how does one read or write to a pipe? or maybe some kinda example Many thanks, you're saving my life ;) Best greetings

            L 1 Reply Last reply
            0
            • C Chaser92

              I get it, but as I don't know much about unmanaged coding, could you tell me how does one read or write to a pipe? or maybe some kinda example Many thanks, you're saving my life ;) Best greetings

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You can read/write to the pipe just like it is a file. Unmanaged code this would be the WriteFile Function[^]. Best Wishes, -David Delaune

              T 1 Reply Last reply
              0
              • L Lost User

                You can read/write to the pipe just like it is a file. Unmanaged code this would be the WriteFile Function[^]. Best Wishes, -David Delaune

                T Offline
                T Offline
                thiagofiora
                wrote on last edited by
                #7

                Hi Randor, I want to redirect the output of another process too, but in Windows Mobile. SetStdioPathW seems to work only in Windows CE. Do you know a function like SetStdioPathW that work at Windows Mobile? Thanks in advance.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups