gile 发表于 2016-4-8 05:35:28

我怎样才能隐藏accoreconsole.exe窗口?

如何隐藏控制台窗口.exe?using cad = Autodesk.AutoCAD.ApplicationServices.Core.Application;。
...。
if(null != cad.主窗口) // 此处为空。
计算机辅助设计,MainWindow.Visible = false;我在 Process.GetCurrentProcess() 中也没有看到类似的属性或方法。
**** Hidden Message *****

白二少 发表于 2016-4-8 05:51:39

嗨,
ProcessStartInfo类型有一个WindowStyle属性。
您可以使用AcCoreConsole流程执行类似的操作:



流程。StartInfo . window style = ProcessWindowStyle。隐藏;

伤心俱乐部 发表于 2016-4-8 06:20:19

谢谢你的回答,gile。如果已经启动了accoreconsole.exe,则此属性更改没有帮助(我的代码位于AutoCAD的. net扩展中)。我还尝试使用FreeConsole()winapi函数:。
静态extern bool FreeConsole();在这种情况下,控制台窗口将成功关闭(而不是隐藏),然后我的类和初始化()方法的静态构造函数的代码也将成功工作,但在它之后,accore控制台进程将完成(即使不调用Terminate()和ProcessExit):使用系统;。
使用System.ServiceModel;。
使用cad=Autodesk.AutoCAD.ApplicationServices.Core.Application;。
使用Autodesk.AutoCAD.ApplicationServices;。
使用Autodesk.AutoCAD.Runtime;。
使用System.Runtime.InteropServices;。
使用System.Diagnostics;。

[程序集:ExtensionApplication(typeof(Bushman.CAD.Services.ExtensionApplication))]。

命名空间Bushman.CAD.Services{。
公共类ExtensionApplication:IExtensionApplication{。


静态extern bool FreeConsole();。

静态ServiceHost主机=null;。

静态扩展应用程序(){。
尝试{。
FreeConsole();。
host=new ServiceHost(typeof(MyService));。
host.Open();。
AppDomain.CurrentDomain.ProcessExit+=ProcessExit;。
}。
捕获(System.Exceptionex){。
文档文档=cad.DocumentManager.MdiActiveDocument;。
如果(null!=doc)doc.Editor.WriteMessage(ex.Message);。
}。
}。

私有静态空ProcessExit(对象发送者,EventArgs e){。
if(null!=host)host.Close();。
}。

公共空初始化(){。
字符串状态=null==host?"null":host.State.ToString();。
文档文档=cad.DocumentManager.MdiActiveDocument;。
if(null!=doc)doc.Editor.WriteMessage("\nHost status:{0}.\n", status);。
}。

公共无效终止(){。
//这里什么都没有,。
}。
}。
}。
页: [1]
查看完整版本: 我怎样才能隐藏accoreconsole.exe窗口?