Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Multiple icons compiled within an .exe

Multiple icons compiled within an .exe

Scheduled Pinned Locked Moved C#
csharptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cdengler
    wrote on last edited by
    #1

    I have a C# application. This C# application also has file types associated with it (in my case, the extenion is .drb). I want to have a DIFFERENT icon compiled within my .exe that these file extensions use, however, I cannot figure out HOW to add additional icons to be compiled within my application for use by these extensions? Am I making sense?

    R H 2 Replies Last reply
    0
    • C cdengler

      I have a C# application. This C# application also has file types associated with it (in my case, the extenion is .drb). I want to have a DIFFERENT icon compiled within my .exe that these file extensions use, however, I cannot figure out HOW to add additional icons to be compiled within my application for use by these extensions? Am I making sense?

      R Offline
      R Offline
      Roman Rodov
      wrote on last edited by
      #2

      Add an icon file to your project, select the file in Solution Explorer and now in the Properties pane change the Compile property to "Embedded Resource". After that follow standard procedure for adding file associations/icons.

      H 1 Reply Last reply
      0
      • R Roman Rodov

        Add an icon file to your project, select the file in Solution Explorer and now in the Properties pane change the Compile property to "Embedded Resource". After that follow standard procedure for adding file associations/icons.

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        That won't work. Embedded Resources != Win32 resources. The icons have to be accessible to Win32. Embedded resources are not. See my reply to the poster if you want to know more information.

        Microsoft MVP, Visual C# My Articles

        1 Reply Last reply
        0
        • C cdengler

          I have a C# application. This C# application also has file types associated with it (in my case, the extenion is .drb). I want to have a DIFFERENT icon compiled within my .exe that these file extensions use, however, I cannot figure out HOW to add additional icons to be compiled within my application for use by these extensions? Am I making sense?

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          The other reply wouldn't work. Embedded resources are stored differently than Win32 resources (in C/C++, these would be referenced in the .rc file). There are many ways you can do this. You can use the command-line compiler (csc.exe) and specify the /win32res: switch along with the path to a .res file that contains your win32 resources. In Visual Studio 2005, you will be able to specify this in the environment, which wasn't available in Visual Studio .NET 2002 and 2003. You can also - after compiling - open the executable (.EXE or .DLL) in Visual Studio. That will show you your resource section. You can import icons and other resources types into the PE/COFF executable (the executable format on Windows). If you sign your assemblies (and there's no reason not to - it's easy), you should resign them to make sure the hash is correct (shouldn't be a problem, but follow along anyway). Use sn.exe -R MyApp.exe KeyPair.snk, where MyApp.exe is the assembly to be signed (of course) and KeyPair.snk is the path to the key pair you used to sign the assembly in the first place. Usually it's a good idea to enable delayed signing (using the AssemblyDelaySignAttribute) and sign it later anyway, and if you use Authenticode to sign the assembly (the PE/COFF executable, actually) then you'll definitely need to resign it after modifying it (or just don't sign it before modifying it anyway). Again, Visual Studio 2005 will include this functionality into the IDE, which will be nice. Alternatively, you might consider just using a native resource-only DLL with the icons you want. Create a new (unmanaged) C or C++ DLL project, add your resources (icons, bitmaps, AVIs, etc.), compile and distribute. The only problem with this approach is that Fusion (the assembly binder which can work seemlessly over the Internet) won't grab it - it only works with .NET assemblies. With installation deployments or (presumably) ClickOnce - a new touchless deployment in .NET 2.0 - this won't be a problem.

          Microsoft MVP, Visual C# My Articles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups