Missing shcore.dll after compiling with target Windows 7 - c++

I need to compile a VC++ VS2015 project I'm working on as a binary compatible with Windows 7. I'm using Win10 and VS2015 with v140 compiler.
As specified in this page I set the target platform to 8.1 and modified the targetver.h such as this:
#include <WinSDKVer.h>
#define WINVER 0x0601
#define _WIN32_WINNT 0x0601
#include <SDKDDKVer.h>
Obviously, it compiles correctly, but when I execute the binary on a windows 7 pc, it gives me "Missing shcore.dll", which, from what I gather is a dll available only from Windows 8.1 onwards and makes me think that I've done something wrong or there's something I'm missing.

I just had the same error on Win7 and unfortunately the DLL is not available for Windows 7. Just on Windows 8.1 and higher.
shcore.dll on Windows 7 -- does it exist?
Hope that Helps!

I got this error too while launching a WPF app on Windows 7. The good news is the error is trapped and handled internally, you can probably just ignore the exception and let the program run. Worked for me.

Related

How to use Visual Studio 2019 to target Windows 7?

I would like to use Visual Studio 2019 to enjoy the latest C++ additions, but targeting Windows 7.
I created a Windows C++ application using the VS 2019 wizard (running on Windows 10).
A targetver.h file is created by the wizard, with the following content:
#pragma once
// // Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
I followed the instructions in the comment lines, and added the following lines intargetver.h (before the #include <SDKDDKVer.h> line):
// Target Windows 7 SP1
#include <WinSDKVer.h>
#define _WIN32_WINNT 0x0601
To test that, in the program's main function I invoked an API (PathCchAppend) that is not supported in Windows 7.
The program builds fine (I statically link the CRT), and runs fine in Windows 10.
The same program fails when executed in Windows 7, showing the following error message:
Now, the program should have not compiled at all, because I specified the Windows 7 target, and the aforementioned API is not available on Windows 7.
Is this a bug in the Windows SDK?
Is it possible to target Windows 7 using VS 2019 and the Windows 10 SDK, getting errors during the build process when an API or structure that is not supported in Windows 7 is used in the code, and how?
VS 2019's toolset and the latest Windows 10 SDK support targeting Windows 7 Service Pack 1.
You have already configured the Windows headers in the Windows 10 SDK properly:
#include <winsdkver.h>
#define _WIN32_WINNT 0x0601
#include <sdkddkver.h>
You can still call APIs that are not supported by Windows 7 in this mode, which is why calling PathCchAppend builds, links, and fails at runtime.
The problem you are seeing may also be related to the Universal C/C++ Runtime not being on your target machine. Install the x86 and/or x64 native version on your target test machine.
See Microsoft Docs.

Targeting the Windows 7 OS with Visual Studio 2017 gives a ucrtbased.dll missing error

I have a client that is running a Windows 7 machine and I want to him build an .exe that he can run on his computer. However, since I am running Windows 10, I am building everything in Visual Studio 2017. The program I am making is a Winforms CLR C++ program. I put in the Windows 7 WINVER define in one of the C++ files:
#define WINVER 0x0601
The compile the project with the following properties:
I send him an .exe file but when he opens it up, it gives him a an error saying that he is missing the ucrtbased.dll. I verified that he has the correct .NET framework installed on his computer:
What could be the cause of this?
Build and send him a release copy. He will still need the appropriate windows libraries.
ucrtbase (Universal C Runtime) is the replacement for the msvc* runtime dlls.
To get the correct runtime, see https://www.microsoft.com/en-us/download/details.aspx?id=48234
and also possibly https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows
if you have problems.

Visual Studio 2010 win32 compiled application does not work on windows xp

I'm working on a project that should run on all windows platforms. It is written in c++, using only the Windows API. When I compile it in Visual Studio 6 on Windows XP, I can run it on Windows XP. When I run it in Visual Studio 2010 and run it on Windows XP it did not work. I did install vcredist2010_x86, vcredist2010sp1_x86 and .NET versions 3.5 and 4.0 on Windows XP SP3. But it still doesn't work. I added the following preprocessor symbols to my project:
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x0501
but it still doesn't work. My VS 2010 platform toolset is v100.
Question: What do I need to do to compile an application using Visual Studio 2010, that can be executed on Windows XP?
I'm using VS2010_sp1 on window_7_sp1_x64 and with 'release' mode.
I added #define previous to my include section.
And I've tested NTDDI_VERSION to 0x05010300 but problem is still alived! The error, showed by win_xp is:
"program.exe has encountered a ploblem and needs to close."
At all, I think, program needs dll or something to install on windows xp to run correctly!

How do I compile for Windows XP with Visual Studio 2012?

Ok, so I'm using Visual Studio 2012 in Windows 7 x64 for programming and compiling. My application works fine there, but when I try to execute it from a Windows XP SP3 Virtual Machine, I get "xxxx.exe is not a valid win32 application" right away.
The application is being compiled with static linking, that is, with /MT. I have set _WIN32_WINNT to 0x0501 in targetver.exe; the configuration manager is set to Win32 and the target machine in the Linker advanced options is set to MACHINEX86.
My targetver.h looks like this:
#include <winsdkver.h>
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x0501
#include <SDKDDKVer.h>
I also tried compiling with /MD and installing .NET Framework, but that didn't help either.
I'm clueless, and I could really use some help as I need to have it working for Windows XP.
VC++ 2012 RTM did not support Windows XP – that support came later in 2012 in Visual Studio 2012 Update 1.
The CTP of Windows XP targeting with VC++ 2012 could be installed, but you would have to link the CRT statically in order to deploy. See this blog article for more information.
Visual Studio 2012 Update 1 added official support for running applications built with VC++ 2012 on Windows XP as well as the ability to link the CRT dynamically.
Download link
Blog article containing additional information
Two things should be done:
Configuration Properties → General page, change Platform Toolset to: Visual Studio 2012 - Windows XP (v110_xp);
Menu Linker → System. Change Subsystem to: Console/Windows.
A detailed explanation is here: http://software.intel.com/en-us/articles/linking-applications-using-visual-studio-2012-to-run-on-windows-xp
When you generate the EXE file, the version for 32-bit will be in the project folder bin\x86\Release.

Explorer thumbnails (winXP)

I have a file format I need to be able to show in explorer thumbnails. Since the target system is windows XP, the Vista PreviewHandler API will not be suitable. Ill be using c++.
How would I do it?
You'll need to register a shell extension for your file type. The extension contains code that extracts/generates the thumbnail by implementing the IExtractImage interface.
See: IExtractImage Interface on MSDN
https://github.com/reliak/moonpdf/tree/master/ext/sumatra/src/previewer is perfect example.
To build both x86 and x64 versions of DLL I use VS 2010 with SP1 along with Win7 x64 SDK (for <thumbcache.h>) installed on Windows 7 x64. Builded DLLs works fine on Win7 and Win10 of either bitness.
Also don't forget /MD linker flag to avoid necessity to install Microsoft Visual C++ 2010 Redistributable Package (x86) on WinXP.
Next lines may be added to "targetver.h" to avoid import and using of new functions from newer versions of Windows system DLLs (say, there is no RegDeleteTreeW in WinXP's advapi.dll):
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#include <winsdkver.h>
#include <SDKDDKVer.h>
Additionally it has implementation of previewer for some file formats, but related interfaces can be completely omitted in your implementation.