Share via


How to create the manifest file and embed in application to detect Windows 10 & 2016 server version

Question

Wednesday, May 17, 2017 12:44 PM

All,

Currently we are upgrading our product to detect the windows 2016 server. Currently we use getVersionEx function to retrieve the required version information of the OS but we see like this function was deprecated from windows 8.1 platform onward. We also had a search on the alternative from the MS end where we found some info on version helpers function and we decided to use the same in our program but the problem here is the function returns false even on Windows 2016 server.

In order to proceed further we made some more search on this part, where in some of the blog we came across the manifesting the GUID in application to the detect the values. Currently we use Visual studio 2016 IDE where we can see the intermediate manifest file is being generated by default. I would like to know the information on the below query

1. Can you please share the complete step by step procedure on how to create the manifest file and embed the same with application?

Though we could see some information on manifest file but its not on the complete part.

We are not aware of creating or editing the manifest file and embedding the same into application using Visual studio. Could you provide your expertise that will help us to move forward

Thanks,

Dinesh

All replies (8)

Wednesday, May 31, 2017 6:40 AM âś…Answered

Hi DineshK16,

thanks for posting here.

If your case has been solved, please help to mark answer.

Your understanding and cooperation will be grateful.

Best Regards,
Sera Yu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


Wednesday, May 17, 2017 12:54 PM | 1 vote

It is in MSDN :

Targeting your application for Windows

I tested on Windows 10 with VS 2015  (I simply added the manifest file as resource) and it works for functions like IsWindows10OrGreater()


Wednesday, May 17, 2017 2:31 PM

(I simply added the manifest file as resource), can you please share the information like how to do that?

We are pretty new with manifest inclusion part so it would be helpful for us


Wednesday, May 17, 2017 3:29 PM

See for example : How to: Add or Remove Resources


Wednesday, May 17, 2017 3:48 PM | 4 votes

If you are building your application normally with Visual Studio, then the compiler and linker should be automatically generating a manifest and adding that as a resource to your application.

You can check this out by looking at two settings. In Project Properties->Configuration Properties->Linker->Manifest File, there should be a setting Generate Manifest (the default option is yes). Next check Project Properties->Configuration Properties->Manifest Tool->Input and Output and look for the embed manifest setting, this should be yes.

If you have both of these set to yes then the linker will embed it as a resource automatically and you don't have to do anything. Anyway the resource file itself can be external if you put it in the same directory as the executable file and name it the same as the executable with a .manifest extension. (I seriously mean exactly the same, including the .exe extension, so if your application is named application.exe, then the manifest must be named application.exe.manifest).

Either way, the easiest way to merge the version compatibility settings actually doesn't involve messing around with the main manifest file settings. If you take just the compatibility elements from the sample manifest and put them into their own separate manifest file, then you can merge those settings with the application manifest.

So lets go through this step by step. First take the version information and put them into their own file. It will look like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
        <application> 
            <!-- Windows 10 --> 
            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
            <!-- Windows 8.1 -->
            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
            <!-- Windows Vista -->
            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
            <!-- Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
            <!-- Windows 8 -->
            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
        </application> 
    </compatibility>
</assembly>

This is all you need in there. You can also add this file to your project too. Then go to Project Properties->Configuration Properties->Manifest Tool->Input and Output and in the Additional Manifest Files setting put the name of your new manifest file.

When you build, it will them merge this manifest with the generated application manifest. The generated file I get is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedOS>
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedOS>
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>
    </application>
  </compatibility>
</assembly>

I made it more readable because it doesn't generate white spaces. You can also verify this by extracting the manifest resource file from the executable or by not embedding the manifest file and look at what it generates. And finally some screenshots to show this in action.

Hope this helps.

This is a signature Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.


Saturday, May 27, 2017 7:30 AM

Kudos to you !!! The information that was provided from your end was way beyond and which really helped us to learn out and implement the same in our system. I could see this as one of the best reply in the MSDN communities. Also the effort you took to explain the application manifesting process along  with step by step instructions was really appreciated. Now we have successfully implemented this method and things are on track now. Apologies for my late response on this and this was really helpful to us.

Hope to interact with you in future with more new queries :-)


Tuesday, June 30, 2020 8:15 PM

That's great information! However, where did you save the version.manifest file? Also, you mentioned that the external manifest filename should be exactly same as the application. Then why did you name it as version.manifest? 


Wednesday, July 1, 2020 12:35 PM

The file was just saved in the project directory. As an example, here is one project that I have done it on:

It uses a different name since I have the high DPI manifest settings in there too.

This is then referred to in the project properties:

But the manifest doesn't have to be in there to be found. If you want to share it across several solutions, you can. You just need to modify this path to point to it. Each project sets the location of the project files (in this case .vcxproj) as the current directory.

Also, the reason why I don't name this the same as the filename is because this isn't the external manifest file.

When you build with the IDE, the linker generates a manifest file. The IDE then merges the manifest that the linker generates and any additional manifest files together and this becomes the main manifest file.

Also notice that the option for Embed Manifest is set to yes. This means that this will not be an external manifest, the manifest generated will be set as resource 1 for the executable.

Basically, any manifests that you use in this manner are processed to become the main manifest. So even if this Embed Manifest option was set to no, it would be the output of mt.exe, which includes the partial manifest you provided, would be named the same as the executable with the .manifest extension.

This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.