Res2exe strips out program icon
I've found two solution around this problem:
***************** FIRST SOLUTION *************************************
Make a copy of the hidpi.res file into your project folder.
Open it in VS.NET (or your favourite resource editor)
Click with right mouse button on hidpi.res for adding a resources, import
the .ico file and set the ID of the icon resource
to 32512
Add any other resources to the project if you so wish, like VERSIONINFO
etc,
as these will also disappear.
Important, it appears you then need to remove the name of the icon from
the
project properties, otherwise it will not go
hires
Save the modified hidpi.res file in your project's path and alter two
lines
in the hires macro.
Change:
Dim ResFile As String = """" + SecondEditionResources + "\hidpi.res"""
to
Dim ResFile As String = """" + ActiveProject.Properties.Item("LocalPath").
Value + "\hidpi.res"""
Change the line
Dim ActiveProject As Project = DTE.ActiveWindow.Project
to
Dim ActiveProject As Project = DTE.Solution.Projects.Item(DTE.Solution.
SolutionBuild.StartupProjects(0))
Then it won't fail with an error if a project window isn't in focus.
I also made one other change, as I found if I didn't save the project
first
then it sometimes didn't build hi-res aware, so I
added the line:
ActiveProject.Save()
after the "Dim Solution ..." line
I haven try to get it to work with the cabinet builder, and It work all
OK!
You can see the new debug and release macro for hires projects below:
================== The modify MACRO HIRES ================================
Imports EnvDTE
Imports System.Diagnostics
Public Module hires
Sub hires_dbg()
' Path for 2nd Edition Resources. You may need to change this to
match your setup.
Dim SecondEditionResources As String = "C:\Program Files\Developer
Resources for Windows Mobile 2003 Second
Edition\tools\"
Dim ActiveProject As Project = DTE.Solution.Projects.Item(DTE.
Solution.SolutionBuild.StartupProjects(0))
Dim Solution As SolutionBuild = DTE.Solution.SolutionBuild
ActiveProject.Save()
' Create the command line for marking the output file as resolution
aware
Dim ResFile As String = """" + ActiveProject.Properties.
Item("LocalPath").Value + "\hidpi.res"""
Dim Params As String = " -r -c "
Dim Res2Exe As String = """" + SecondEditionResources + "\res2exe.
exe"""
Dim OutputFile As String = """" + ActiveProject.Properties.
Item("LocalPath").Value + "\obj\Debug\" +
ActiveProject.Properties.Item("OutputFileName").Value + """"
Dim Command As String = Res2Exe + Params + ResFile + " " +
OutputFile
' Build, mark has resolution aware, and then launch the debugger
Solution.BuildProject("Debug", ActiveProject.UniqueName, True)
Shell(Command, AppWinStyle.Hide, True)
DTE.Debugger.Go(True)
End Sub
Sub hires_rls()
' Path for 2nd Edition Resources. You may need to change this to
match your setup.
Dim SecondEditionResources As String = "C:\Program Files\Developer
Resources for Windows Mobile 2003 Second
Edition\tools\"
Dim ActiveProject As Project = DTE.Solution.Projects.Item(DTE.
Solution.SolutionBuild.StartupProjects(0))
Dim Solution As SolutionBuild = DTE.Solution.SolutionBuild
ActiveProject.Save()
' Create the command line for marking the output file as resolution
aware
Dim ResFile As String = """" + ActiveProject.Properties.
Item("LocalPath").Value + "\hidpi.res"""
Dim Params As String = " -r -c "
Dim Res2Exe As String = """" + SecondEditionResources + "\res2exe.
exe"""
Dim OutputFile As String = """" + ActiveProject.Properties.
Item("LocalPath").Value + "\obj\Release\" +
ActiveProject.Properties.Item("OutputFileName").Value + """"
Dim Command As String = Res2Exe + Params + ResFile + " " +
OutputFile
' Build, mark has resolution aware, and then launch the debugger
Solution.BuildProject("Release", ActiveProject.UniqueName, True)
Shell(Command, AppWinStyle.Hide, True)
DTE.Debugger.Go(False)
End Sub
End Module
[Original Author: Robert Levy]
***************** SECOND SOLUTION
*************************************
The second solution is very simply!
You must remove from your original hires macro the option -r
Change the line
Dim Params As String = " -r -c "
to
Dim Params As String = " -c "
In this way the icon information of your application is no lost after you
use res2exe, but you must remember to rebuild zone
of your application everytime before you lunch the hires macro!
Hope this helps
... an italian .net programmer
(e-mail address removed)