1

I need to find the version number of own running process. Something equivalent to following from .NET into C++.

Assembly.GetExecutingAssembly().GetName().Version

I came across this similar question and the solution provides me the necessary functionality. However, I had to add Mincore.lib in the linker settings. Problem is that now when I try to run this application on different environments, I get the following error.

enter image description here

How can I deal with this issue? Do I need to add include api-ms-win-core-version-I1-1-1.dll in the linker too? Looks like the Mincore.lib depends on a bunch of api-ms-win-***** libraries, so not sure what else I will have to include too. Hopefully there is an elegant solution?

UPDATE:

This is what its currently set to.

enter image description here

Following is a list of available options. enter image description here

whoami
  • 1,689
  • 3
  • 22
  • 45
  • You need to ship *all* libraries you link with. – Jesper Juhl Apr 16 '19 at 14:02
  • This looks like an OS related library. So I need to find all the dependencies of this library and include all of those with my application? – whoami Apr 16 '19 at 14:12
  • 1
    if you are building with Visual Studio, you need to ship the Visual Studio redistributable runtime libraries, always. Anything your application links with needs to be available when it runs. A lot of stuff comes from the standard library which you get from the VS redistributables. For other libraries, yeah, you need to package those as well. How would you expect your code to be able to run something in a library if you don't ship said library with the application? – Jesper Juhl Apr 16 '19 at 14:14
  • 1
    These libraries should be present in the system. Are you sure that you are running this on Windows 10? – user7860670 Apr 16 '19 at 14:30
  • @VTT My application can run on a variety of OS including Windows 8, Windows 10, 2012 etc. The test I ran was on a window 2012 OS where I am currently getting this error. – whoami Apr 16 '19 at 14:46
  • @JesperJuhl I am only linking to Mincore.lib in my project. The error happens only when I run the application. So I need to find all the dependencies of Mincore.lib and include all of those with my application? – whoami Apr 16 '19 at 14:47

1 Answers1

1

Most likely you are not targeting appropriate SDK versions. Note that version functions has been moved around a lot:

Introduced into api-ms-win-core-version-l1-1-0.dll in 10.0.10240. Moved into api-ms-win-core-version-l1-1-1.dll in 10.0.10586. Moved into api-ms-win-core-version-l1-1-0.dll in 10.0.14393.

When targeting Windows 7 and older it should be imported directly from version.dll.

user7860670
  • 35,849
  • 4
  • 58
  • 84
  • Can you point out where the SDK version is targetted within Visual Studio? I only added MinCore.lib in the linker as without doing that, I get link errors. The errors I am getting now is when I am running the program on different computers ( and not the development machine itself) – whoami Apr 16 '19 at 16:14
  • @BKS It is listed on General tab of C/C++ project properties. You should set SDK version corresponding to the oldest system that you are trying to support. – user7860670 Apr 16 '19 at 16:18
  • I have updated my question with more details on the SDK version. I try to google what SDK version maps against the Windows OS flavors. All other things that I used so far seem to work fine on Windows Server 2012 except the GetFileVersionInfo API. – whoami Apr 16 '19 at 17:28
  • @BKS I think in order to support Windows Server 2012 you will need to install and target Windows 8 SDK. – user7860670 Apr 16 '19 at 18:59