是否可以从 .net 更改控制台窗口的图标?
是否可以从 .net 更改控制台窗口的图标? 不使用 win32 调用。
Is it possible to change a console window's icon from .net? Without using win32 calls.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果它是您自己的应用程序的控制台窗口,那么您可以...
(我假设您处于 C# 环境中,但 VB.NET 应该类似)
如果您正在启动外部进程...那么您可以创建一个“启动器”控制台项目,您可以将自己的图标设置为相同的方式如上。
如果您的意思是您无法控制的外部拥有的控制台窗口...那么我认为您确实需要 win32/pinvoke 调用。
If it is your own application's console window, then you can...
(I'm assuming you are in a C# environment, but VB.NET should be similar)
If you are starting an external process... then you can make a "launcher" console project to which you can set your own icon the same way as above.
If you mean an externally owned console window that you don't have control over... then I think you do need win32/pinvoke call.
正如 Chakrit 建议的那样,我在项目属性中设置了图标,但我的问题是我是从 Visual Studio 运行它,它运行 app.vshost.exe,而不是直接运行 app.exe。
由于 app.vshost.exe 没有图标,因此即使配置正确,它似乎也无法工作。
I had the icon set in the project properties, as Chakrit suggested, but my problem was that I was running it from Visual Studio, which runs app.vshost.exe, not app.exe directly.
Since app.vshost.exe didn't have the icon it was appearing not to work, even though it was configured correctly.
通常,当应用程序从 vshost 运行时,您无法将图标分配给应用程序的窗口。 当它在 IDE 外部运行时,它会正常工作,前提是您在项目属性对话框中设置自定义图标。
Generally, you cannot assign an icon to the window of the application when it is running from vshost. It will work correctly when it is running outside the IDE, with the condition that you set a custom icon in the Project Properties dialog.