redirecting standarderror from a messagebox

R

robiman

Hi,

I'm running an external program using System.Diagnostics Process. This
program creates a PDF file from a CAD file via commandline "me10f.exe -
p filename.mi". But in case of errors the program reports this with a
messagebox, not on the console.

Can someone tell me if it is possible to:
- disable/hide the popup errors from external app?
- catch the error messages via standarderror or some other way?

I have tried debugging this, but with no success - ExitCode is always
0, and I got nothing in StandardOutput and StandardError streams.

string CoCreatePath = @"C:\......\ME10F.exe";
Process proc = new Process();
proc.StartInfo.FileName = CoCreatePath;
proc.StartInfo.Arguments = "-p " + fileName;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.WaitForExit();
 
K

Kerem Gümrükcü

Hi,
Can someone tell me if it is possible to:
- disable/hide the popup errors from external app?
- catch the error messages via standarderror or some other way?

hook the process, catch the creation of the message box, enumerate
its child windows until you find the static child window, get its text,
destroy the messagebox, mark the windows message as handled
and do with the text you got whatever you want. The Control ID
for the Static Control inside the MessageBox is 65535 to make the
things easy for you. Get the Control with the ID inside a MessageBox
and you will have the Error Text Message of the Application!

Thats the way how it works,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
(e-mail address removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
 
R

robiman

hook the process, catch the creation of the message box, enumerate
its child windows until you find the static child window, get its text,
destroy the messagebox, mark the windows message as handled
and do with the text you got whatever you want. The Control ID
for the Static Control inside the MessageBox is 65535 to make the
things easy for you. Get the Control with the ID inside a MessageBox
and you will have the Error Text Message of the Application!

Can you be more specific - some examples perhaps? I guess you mean
doing this with Win32 API calls?
 
K

Kerem Gümrükcü

Hi,

yes, this a mixture of pinvoke/win32 api and netframework.
Explaining this would be a little to long but you have to subclass
the window of desire and whatch for some sort of window messages.
Best would be when you see some code and codeproject is the
best place for it. Go to www.codeproject.com and do a search
with "SetWindowsHookEx MessageBox". Once you got the
MessageBox do a EnumChildWindows(...) on it and then a GetDlgCtrlId(...)
inside the EnumChildWindows Callback with the ID i told you to get the
Static Control with Text for the Message. So it will be done! Maybe a
FindWindowEx() will do the same for you inside the Callback.

I hope this helps,...


Regards

Kerem

-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
(e-mail address removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top