- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there, I have a simple question:
Assuming that I already have an .ICO file, how do I change the program icon for a console application?
Link Copied
- « Previous
- 
						- 1
- 2
 
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan, did you forget attaching the source files? Or don't I just see them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I started having problem with setting the icon for my console application. Everything worked well, but for some reason (could it be Update 2 of IVF Studio?) it does not work anymore, even though I did not change anything in the respective code that reads:
      use ifwin
      use iso_c_binding
      
      pointer SetConsoleIcon
      interface
        integer function SetConsoleIcon ( hIcon )
        !dec$ attributes default, stdcall :: SetConsoleIcon
        use iso_c_binding
        integer(kind=c_intptr_t) :: hIcon
        end function SetConsoleIcon
      end interface
      
      integer(kind=c_intptr_t) :: hMainMod, hLib, hIcon, SetConsoleIcon_Address
      integer,parameter :: IDI_ICON_REDOX=101
      integer :: iResult
      
      hMainMod = GetModuleHandle ( NULL )
      hIcon = LoadIcon ( hMainMod, IDI_ICON_REDOX )
      hLib = LoadLibrary ( "Kernel32.dll"//C_NULL_CHAR )
      
      SetConsoleIcon_Address = GetProcAddress ( hLib, "SetConsoleIcon"//C_NULL_CHAR )
      call C_F_PROCPOINTER(TRANSFER(SetConsoleIcon_Address, C_NULL_FUNPTR), SetConsoleIcon)
      
      iResult = SetConsoleIcon ( hIcon )
I verified that I have the icon IDI_ICON_REDOX in my resources and that no changes were done for this part of the code. Am I missing something?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you changed windows version? SetConsoleIcon is not a documented API in Kernel32 so it may disappear without warning at some future windows release.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, I have not changed Windows 7 Pro 64-bit since 4 years ago. Or do you mean also Service Packs?
If I am using an undocumented API, is there an official and documented way how to change the console window's icon?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have recompiled a program that is similar to the one that I send with #16 and that runs fine under Windows 8.1, 64 bits. So it is still in the SDK. I am not aware of an "official" method to change the console icon that is different from the "illegal" SetConsoleIcon.
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I used your approach from #16 and it worked well, but is does not work now and I could not figure out why. Checking Resources.rc showed that resource.h is included and I had a wrong name for the icon resource in the #define statement. Correcting this line in resource.h got everything work well again.
Thank you for your tests and kid support; I appreciate it.
 
					
				
				
			
		
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
- 
						- 1
- 2
 
- Next »