Manifests

Just starting out? Need help? Post your questions and find answers here.
mikejs
Enthusiast
Enthusiast
Posts: 175
Joined: Thu Oct 21, 2010 9:46 pm

Manifests

Post 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...
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Manifests

Post by jassing »

Actually, the "did this install" is not (directly) related to a manifest... It has more to do with the exit code.
mikejs
Enthusiast
Enthusiast
Posts: 175
Joined: Thu Oct 21, 2010 9:46 pm

Re: Manifests

Post 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?
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Manifests

Post 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.
mikejs
Enthusiast
Enthusiast
Posts: 175
Joined: Thu Oct 21, 2010 9:46 pm

Re: Manifests

Post 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.
mikejs
Enthusiast
Enthusiast
Posts: 175
Joined: Thu Oct 21, 2010 9:46 pm

Re: Manifests

Post 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.
moogle
Enthusiast
Enthusiast
Posts: 372
Joined: Tue Feb 14, 2006 9:27 pm
Location: London, UK

Re: Manifests

Post by moogle »

Out of interest how does one create a program that returns an exit code?
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Manifests

Post by ts-soft »

moogle wrote:Out of interest how does one create a program that returns an exit code?

Code: Select all

End 1000
:wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
moogle
Enthusiast
Enthusiast
Posts: 372
Joined: Tue Feb 14, 2006 9:27 pm
Location: London, UK

Re: Manifests

Post by moogle »

ts-soft wrote:
moogle wrote:Out of interest how does one create a program that returns an exit code?

Code: Select all

End 1000
:wink:
Ah I'm so silly, I didn't see that :)

Thank you very much
Image
Post Reply