Search code examples
c#winapiiconsresource-filesrc.exe

How to generate .res file containing icons runtime


i need to make the res runtime and it need to contain some icons i have in a list in my application. the res file has to be placed in a project "Resource File" field. so it needs to be win32 compatable.

i so fa tried to:

  • create a .resx file runtime containing the icons and i converted it to a .resources file with ResGen.exe but i ended up in a dead end.
  • i tried to fit the .resx i created in the project "Resource File" but it gives an error saying "the selected file is not a valid Win32 resource file".
  • i also tried to create a .rc file but i can't figure ut how to properly use rc.exe to compile it in a .res file so an other dead end as well...

do you have any idea of how i can achieve this?

if i try to compile a .rc file i get this output:

Microsoft (R) Windows (R) Resource Compiler, Version 5.1.2264.1 - Build 2264

Copyright (C) Microsoft Corp. 1985-1998. All rights reserved.

Using codepage 1252 as default

Creating rc - ResourceFile.res

RC: RCPP -CP 1252 -f C:\Users\itis\Desktop\RCa18040 -g C:\Users\itis\Desktop\RDa18040 -DRC_INVOKED -D_WIN32 -pc\:/ -E -I C:\Users\itis\Desktop\ -I .

C:\Users\itis\Desktop\_mingw.h(51) : error RC2188: #error : ERROR: You must use a GNU Compiler.

C:\Users\itis\Desktop\_mingw.h(55) : error RC2188: #error : ERROR: You must use a GNU Compiler version >= 3.4.5.

C:\Users\itis\Desktop\afxres.h(34) : fatal error RC1015: cannot open include file 'windows.h'.

Premere un tasto per continuare . . .


Solution

  • Using rc.exe to compile a .rc file is the normal way to create a .res file.

    A .rc file might be as simple as this:

    1 ICON "myicon1.ico"
    2 ICON "myicon2.ico"