22

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

Eric Haskins
  • 8,505
  • 12
  • 38
  • 47

3 Answers3

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.

Igor Ševo
  • 5,459
  • 3
  • 35
  • 80
chakrit
  • 61,017
  • 25
  • 133
  • 162
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.

Drag and Drop
  • 2,672
  • 3
  • 25
  • 37
Eric Haskins
  • 8,505
  • 12
  • 38
  • 47
  • 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 02 '09 at 05: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.