22

Is it possible to change a console window's icon from .net? Without using win32 calls.

1
  • 2
    Do you mean your application's icon or any externally-started console window?
    – chakrit
    Aug 17, 2009 at 1:16

3 Answers 3

32

If it is your own application's console window, then you can...

  1. Double-click on "Properties" under your console project in Solution Explorer
  2. Select the option "Icon and manifest"
  3. Add your icon in that panel.

(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.

0
21

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.

1
  • 2
    Actually, I didn't notice the "vshost" problem too til you mention it. :-) ... I just sort of remember that it worked that way.
    – chakrit
    Sep 2, 2009 at 5:31
8

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.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.