Running a DOS application from a DLL and read its output

csharp Ireland
  • 11 years ago


    I am working on a project where, I am creating a DLL, which in turn calls up a exe (MECoder.exe). My objective is to call up exe from DLL and capture all DOS application output in realtime and also show the progress (Percent complete).

    Please help me.



  • 11 years ago

    Calling the .exe is relatively easy - use a Shell.Exec type of command to execute the program, and re-direcect it's output to a file, eg: Shell.Exec("c:\program.exe >> c:\output.txt")

    That will dump all it's output into named file.

    Getting progress (feedback) would be a lot more complex and require call-backs from the .exe, which it probably doesn't have. If you have access to the code, you could modify it to emit some sort of windows message which your .DLL listens for... Tricky process




  • 10 years ago

    It is actually quite easy and straight forward to do in c#. scroll down for a full source code example.
    Also take a look at more specifically StartInfo.CreateNoWindow = true;

    which will allow you to hide the new process window so it doesn't get shown.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only two kinds of languages: the ones people complain about and the ones nobody uses” - Bjarne Stroustrup