Page 1 of 1
Manifests
Posted: Wed Apr 10, 2013 10:02 am
by mikejs
I have a program which, amongst other things, is used to launch setup programs for other applications.
Sometimes (but not always for some reason), when I close the application I get the Windows Program Compatibility Assistant popping up asking whether my application installed correctly. Having googled, one answer seems to be to include a manifest in the exe, something like this:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>
How would I go about doing this?
Is there a way of having the pbcompiler do it, or is it something I would have to do to the binary afterwards using separate tools?
(I'm currently compiling this project using the IDE command line parameters, to build separate sets of 32 and 64bit binaries, if that makes any difference.)
Thanks for any help on this one...
Re: Manifests
Posted: Wed Apr 10, 2013 5:20 pm
by jassing
Actually, the "did this install" is not (directly) related to a manifest... It has more to do with the exit code.
Re: Manifests
Posted: Thu Apr 11, 2013 8:45 am
by mikejs
Interesting. I had wondered about that, but changing it to explicitly exit with an errorcode of 0 made no difference.
I'm guessing there isn't an easy answer to the manifest question then?
Re: Manifests
Posted: Thu Apr 11, 2013 9:02 am
by Danilo
mikejs wrote:I'm guessing there isn't an easy answer to the manifest question then?
To try if it makes a difference, use
ResEdit Resource Editor to change the manifest of your compiled .EXE.
Just insert the "<compatibility .... </compatibility" lines in the manifest section with ResEdit and try it.
Re: Manifests
Posted: Thu Apr 11, 2013 11:51 am
by mikejs
Danilo wrote:mikejs wrote:I'm guessing there isn't an easy answer to the manifest question then?
To try if it makes a difference, use
ResEdit Resource Editor to change the manifest of your compiled .EXE.
Just insert the "<compatibility .... </compatibility" lines in the manifest section with ResEdit and try it.
So far I just get side-by-side errors, and messages in event viewer about the XML being invalid (looks right to me, but clearly not to windows).
Interestingly, if I take a working binary, load it into resedit, make no changes but just press CTRL+S to resave it, I get a broken binary that gives me errors in event viewer and a message about the side-by-side configuration when I try to run it. Maybe the XML that PB puts there is valid as far as windows is concerned, but ResEdit doesn't understand it properly? (This is all with PB 5.10, Win7, ResEdit 1.5.11, 64bit everything, including the binary I'm poking around in)
Looks like there are tools in the windows SDK for modifying manifests, so I'll have a tinker with that.
Re: Manifests
Posted: Thu Apr 11, 2013 12:18 pm
by mikejs
Ok, I think I've got somewhere with the mt.exe tool from the SDK.
Several steps to this. First, I exported the basic manifest that PB included:
Code: Select all
mt -inputresource:c:\myprogram.exe;#1 -out:c:\myprogram.base.manifest
Then I created a second manifest file with the following contents, as myprogram.compat.manifest:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>
Then I used mt again to apply both manifests to the binary:
Code: Select all
mt -manifest c:\myprogram.base.manifest c:\myprogram.compat.manifest -outputresource:c:\myprogram.exe;#1
This results in a binary that still works, doesn't generate side by side errors, and - looking at the contents in notepad - does have the relevant chunk of xml at the end. Also, the [NUL] padding that PB leaves behind has changed to a long string of "XXPADDINGPADDING". The icon and other resources are still intact.
mt gives a warning 'Unrecognized Element "compatibility"', but this is apparently a known issue with the current version of the tool, and doesn't seem to affect the results. There's a hotfix for it
http://support.microsoft.com/kb/2670561 but it's one of the ones you have to explicitly ask microsoft for.
The only remaining question is whether all this solves the original Program Compatibility Assistant problem. If it works, then I think I've cracked it, as this can be included in the build script.
Re: Manifests
Posted: Thu Apr 11, 2013 6:12 pm
by moogle
Out of interest how does one create a program that returns an exit code?
Re: Manifests
Posted: Thu Apr 11, 2013 6:37 pm
by ts-soft
moogle wrote:Out of interest how does one create a program that returns an exit code?

Re: Manifests
Posted: Thu Apr 11, 2013 6:41 pm
by moogle
ts-soft wrote:moogle wrote:Out of interest how does one create a program that returns an exit code?

Ah I'm so silly, I didn't see that
Thank you very much