我在阅读一个GUI程序时,发现程序中夹杂着许多Console.WriteLine()
似乎是作者用于输出软件运行信息的。我如何能够得到这些输出信息呢?
程序为C#写的
似乎是作者用于输出软件运行信息的。我如何能够得到这些输出信息呢?
程序为C#写的
解决方案 »
- 调查了3天的问题:在VS中运行与直接运行的区别?
- GDI+的问题
- 如何访问存放在Stream的ACCESS数据库?
- JMail在64位服务器上失败,如何解决?
- 使用Visual C#.NET编写的软件如何打包? (让没有安装.net或是FRAMWORK)的都能运行!)
- 大数据量处理的性能难题,求高人
- 100分求dotnetmagic的类库帮助文档及源代码!
- 未能找到类型或命名空间名称“DBUser”(是否缺少 using 指令或程序集引用?)
- GDI+打印 页面设置的问题? 求助
- 在c#中如何读取excel中的数据
- 求指点:CalendarExtender 控件日历显示不完整的问题
- 时间的一个判断
输出里边会有Console.WriteLine()输出的内容。
[DllImport("Kernel32.dll")]
private static extern bool AllocConsole(); //启动窗口
[DllImport("kernel32.dll", EntryPoint = "FreeConsole")]
private static extern bool FreeConsole(); //释放窗口,即关闭
[DllImport("user32.dll", EntryPoint = "FindWindow")]
extern static IntPtr FindWindow(string lpClassName, string lpWindowName);//找出运行的窗口
[DllImport("user32.dll", EntryPoint = "GetSystemMenu")]
extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert); //取出窗口运行的菜单
[DllImport("user32.dll", EntryPoint = "RemoveMenu")]
extern static IntPtr RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags); //灰掉按钮调用方法如下
AllocConsole();
IntPtr windowHandle = FindWindow(null, Process.GetCurrentProcess().MainModule.FileName);
IntPtr closeMenu = GetSystemMenu(windowHandle, IntPtr.Zero);
uint SC_CLOSE = 0xF060;
RemoveMenu(closeMenu, SC_CLOSE, 0x0);
for(int i=0;i<100;i++)
{
Console.WriteLine("i=:" + i);
}
编译后,点exe运行后,会有一个命令窗口弹出来
因此 能不能不修改原EXE程序
StartInfo.RedirectStandardError
StartInfo.RedirectStandardOutput
详细的你可以搜索一下重定向输出