Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 577785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:11:27+00:00 2026-05-13T14:11:27+00:00

Is there a way to change a WPF assembly icon from code? I’m not

  • 0

Is there a way to change a WPF assembly icon from code? I’m not referring to the window icon, but to the icon that appears on the .exe file.

EDIT:

I’m trying to achieve interactivity in the application icon’s representation – different user-initiated actions combined with a current state should lead to a different application icon. I rely on the visual representation of the application as it has no visible window and the interaction is based on hot-keys and general system usage patterns.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:11:27+00:00Added an answer on May 13, 2026 at 2:11 pm

    Overview

    Changing the icon in your .exe file is straightforward though a bit cumbersome. You’ll potentially need to do three things:

    1. Prevent your running process from holding a lock on the .exe file which would prevent it from being modified
    2. Possibly modify file permissions to make it writable
    3. Actually edit the .exe file to replace the icon

    Details

    Step 3 – actually editing the .exe file – is the most interesting, so I’ll start there. You will use the BeginUpdateResource(), UpdateResource() and EndUpdateResource() calls in kernel32.dll. Basically you do this:

    byte[] data = File.ReadAllBytes(newIconFilePath);
           // Or otherwise load icon data
    
    IntPtr hUpdate = BeginUpdateResource(exePath, false);
    UpdateResource(hUpdate, RT_ICON, MAKEINTRESOURCE(1), LANG_SYSTEM_DEFAULT,
                   data, data.Length);
    EndUpdateResource(hUpdate, false);
    

    You’ll need to add DllImport declarations for the functions and implement the constants. See the documentation on MSDN for details on how BeginUpdateResource, UpdateResource, and EndUpdateResource work.

    For step 1 – preventing your .exe from being locked – the easy solution is to add code to your application startup that checks to see if the current .exe is running from the temporary directory (Path.GetTempPath()). If not, it copies the .exe to the temporary directory using File.Copy() along with any additional files needed, then executes it with one additional command line argument that gives the location of the original .exe. The original process then exits, removing the lock on the .exe file.

    For step 2 – correcting permissions – this simply a matter of modifying the ACLs and possibly triggering a UAC dialog. There are plenty of examples out there and you probably don’t need to do this, so I’ll skip further explanation

    Final note

    The above steps will actually allow you to edit the actual icon of your real .exe file. However if you just need a visual icon change I would recommend you use a shortcut and edit its icon instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 287k
  • Answers 287k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are quite a few problems, but the biggest problem… May 13, 2026 at 5:07 pm
  • Editorial Team
    Editorial Team added an answer Yes. Check out e.g. Top 10 WordPress Gallery Plugins May 13, 2026 at 5:07 pm
  • Editorial Team
    Editorial Team added an answer Have you tried ${model.testhash[model.testkey]} In general the ${ } only… May 13, 2026 at 5:07 pm

Related Questions

I have a few WPF applications and I want all my styles to be
I am trying to modify an existing WPF application for localization. One of my
I have a BaseSkin and multiple UserSkins in a separate dll from my WPF
Is there a way to create a style that extends the current style, i.e.
I need to create a command line look-and-feel in a WPF app. In WPF,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.