Prevent start of program on an old Windows system - c++

We have a minimum System requirement of Server 2012 and Windows 8.1.
We have programs written on C++.
Some programs in our Setup still don't use newer DLLs and start on a Windows 7 or Windows 2008 R2. Some use newer DLLs and don't start with a message that such a DLL isn't found.
Is there a way to prevent the start of a program on an old Windows System with a manifest or something similar? I would prefer that the user don't see a "DLL not found message".
The best way: Windows Loader tells the user that the executable doesn't match this OS.
I know that this works for Windows executables of the OS. Copying a newer EXE from Windows 10 to an old Windows version, even if new specific DLLs are not used.

Related

How to Port Windows Embedded Compact 7 DLL to Windows CE 5.0 / 6.0?

I would like to port a DLL that was compiled for Windows Embedded Compact 7 into a Windows CE 5.0 / 6.0 environment. I'm fairly certain the target assembly language is compatible but from my experimentation it appears that there is something fundamentally different about the DLL's in WEC 7 than in WCE 5. Does anyone know what specifically is different about how the DLL's are compiled in WEC 7 than in WCE 5/6?
I'm assuming the source code for this dll is not available, which could make it difficult to use on earlier versions of Windows CE.
Newer versions of CE have added security features to the CRT library, so if the dll depends on any of those, it would not run on earlier versions.
Besides the target architecture, the OS images would also have to be built using a similar set of OS/SYSGEN features, or, again, the dll might fail to load or run if those dependencies are not satisfied.
The dll could be attempting to dynamically load other dll's, or could be relying on OS behaviour specific to CE 7.0.
In short, a potentially very difficult task without the source code.
A way to get started would be to use the Microsoft dumpbin tool with the /imports option to produce a list of dll's and entrypoints that the dll depends on. Similarly, use dumpbin /exports on the earlier builds of Windows CE that you want to use the dll on, to see what entrypoints are available, and work from there.
Another approach, in case you have access to Platform Builder and are able to generate OS images yourself, would be to use the kernel debugger to examine what happens when the dll is loaded.

api-ms-win-core-winrt-string-l1-1-0.dll is missing from your computer

I'm writing a program that needs to run across Windows 7, 8.x and 10. The program has a one (relatively minor) feature that relies on Windows APIs that are only available on Windows 10. This feature will obviously not work on Win7, and before calling these APIs I make sure that the current OS is Windows 10.
In order to use these APIs I'm forced to configure my VS2015 project to "Consume Windows Runtime Extension" (/ZW) and to set "Target Platform Version" to 10.0.10586.0.
However, this causes a problem when I try to run the app on Windows 7. I get an error dialog saying "The program can't start because api-ms-win-core-winrt-string-l1-1-0.dll is missing from your computer". I tried to installed VS2015 redistributable package on the Win7 machine, but that did not solve the problem.
Any idea on how to get this to run on Win7? I really prefer not to change all my code to dynamically load all Windows 10 functions.
The program is written in C++, and the Windows API I use are from Windows.Devices.WifiDirect namespace.
I ended up solving this problem by moving all my Win10-only API calls into a proxy DLL, which is compiled with /ZW. I then removed the /ZW switch from the main program, which then allowed it to run under Windows 7. The proxy DLL is only loaded (using LoadLibrary() call) when my program is running on a Windows 10 machine.
This solved the problem. I did have to write a few proxy functions for the DLL, but it was far lass overhead than doing that for all the Win10-only API calls.
I would still like to hear better solutions, if there are any.
It is possible to access Windows 10 APIs without using /ZW switch by using the "ABI" API. More details here:
https://blogs.msdn.microsoft.com/oldnewthing/20160629-00/?p=93775
You'll have to use APIs like "RoGetActivationFactory" and "WindowsCreateString" through LoadLibrary/GetProcAddress, since you can't link to them as they're not available on Windows 7. Don't forget to define your WINVER and _WIN32_WINNT to Windows 7:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
That will allow you to not link to any APIs not available on Windows 7.

Which windows subsystem is supported on a recovery disk

When running a standard Windows 7 Installation Disk in recovery mode, if you open up the command line and run a custom-built application you will receive the error 'subsystem not supported'. I have tried linking with /SUBSYSTEM:CONSOLE, WINDOWS and NATIVE, none of these work.
I had a little difficulty with a partition table (and may have found a bug, or at least 'stupid' behaviour from the partition manager included in windows) and so wrote a utility to fix it. My program uses 'Windows.h' to import CreateFile, however if need be I can use only standard C++ (Or even standard C) with no windows specific headers.
What do I need to do to get an application running?
The Windows Recovery Environment is a superset of the Windows Preinstallation Environment.
Windows PE is a stripped down version of windows, lacking many subsystems including WoW (Windows on Windows).
This means that 32bit executables (or anything with a 32bit component) WILL NOT RUN on a 64-bit Windows PE disk. (Note that WinPE 32 cannot install/repair 64 bit systems and vice-versa).
The solution to my problem was to compile to 64 bit code -- a descriptive error message would have been nice Microsoft :|
Found after much searching:
http://technet.microsoft.com/en-us/library/cc766093(v=ws.10).aspx
Are you using the C++ CRT in any way? I don't think that's supported. I'd even doubt that CreateFile is appropriate; and look into NtCreateFile instead.

Want to run a program on some unknown system

I have been working on a VS 2005 project and have successfully generated an exe file which works fine on my system. However when I tried to run it on some other pc it didnt run. It throws up the error message "the system cannot run the specified program". Can someone tell me how to make my code immune to such message i.e. system independent?
platform used: Windows XP, VS 2005
the extension of all my code files is cpp but I know only c and thats what I wrote inside them.
I have seen before exe created on Windows Sp1 not working on SP2 and problems such as that.
This should help you perhaps.
I've seen this when you run on a different version of Windows that doesn't have some DLL you depend on. The easiest thing to do is statically link the C runtime (that's the usual culprit) and use depends.exe to see if there are any others.
You will almost certainly need to create an installer that installs your executable and any non-OS-included DLL's it relies upon. It is not always possible or desirable to statically link all dependencies. You can in many cases simply copy the DLL's to the same folder as the executable.
By default, even the C/C++ standard library is provided by a DLL. While the MSVCRT.DLL used by VC++ 6 is included with the OS since later editions Win95, the MSVCRT required by VS2005 is not included with XP installations (other versions I do not know). The run-time support is included VC redistributes package. You may need to arrange for your installer to include that installation, or you could be more selective is you know your dependencies.
Some Win32 API calls if you are using them are dependent on the OS version (check the documentation), but if you built and rin it on XP, it should normally work of any subsequent version of Windows. You need to define various API version macros if you want to extend support to earlier versions of Windows (which seems unlikley).
You might need to install the VS 2005 redistributables on the other machines, depending on how you have compiled your program.

Building a Volume Shadow Service app for release

How should an application that uses the Volume Shadow Copy service be built for release? I've been building and testing in Windows 7 and everything looks good so I built the app to test in Windows XP and I get an error on startup:
The procedure entry point VssFreeSnapshotPropertiesInternal could not be located in the dynamic link library VSSAPI.DLL
Now, I realise that a way round this is to use LoadLibrary and call the function if it exists but surely the function should exist in the first place to be able to use VSS?
I read somewhere that I would need to build a different version for XP, Server 2003, Windows 7 etc but I've not seen that in other applications that use VSS.
What is the correct way to build a VSS app?
Thanks,
J
Take a look at HoboCopy source code.
This should answer every question you could have.
It's free (for personal use) and C++ src code covers all Windows versions from XP to 2008.
Src has moved, anyway start from here.
Note: The Windows SDK can be used to develop VSS applications only for Windows Vista and later Windows operating system versions. It cannot be used to develop VSS requester's, providers, or writers for Windows Server 2003 R2, Windows Server 2003, or Windows XP.
link: VSS Application Compatibility (Windows)