Running a DOS application from a DLL and read its output

csharp Ireland
  • 12 years ago

    Hello,

    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.

     Regards

    Harsha

  • 12 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

    Regards

    Andrew

     

  • 12 years ago

    It is actually quite easy and straight forward to do in c#. http://msdn.microsoft.com/en-us/library/system.diagnostics.process.outputdatareceived.aspx scroll down for a full source code example.
    Also take a look at http://msdn.microsoft.com/en-us/library/system.diagnostics.process.startinfo.aspx 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).

Contribute

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.

“Perl - The only language that looks the same before and after RSA encryption.” - Keith Bostic