Is it possible to open ac# exe file (console app) from another c # project (windows form) and to write or read different text values from the exe file? i'm using user32dll to handle the exe file.
Thx I did use this method to add a text in an exe file:
Clipboard.SetText("Message!");
foreach (IntPtr pPost in pControls)
{
PostMessage(pPost, (uint)WindowMessage.WM_PASTE, 0, 0);
}
but is not working. I don't see the "Message" post added in c# exe (which is a console app) . Thoug using the notepad.exe everyting is working ok.
You can use the Process
class to execute the command line app and redirect the input/output using the StandardInput
and StandardOutput
properties.
From MSDN:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Write500Lines.exe";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
There are more examples on the StandardOutput
page linked above.
There are a large number of possible failure modes here.
Visit pinvoke.net for (usually) correct pinvoke declarations.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.