Update
I have re-wrote the original question as the previous text was more of a story than describing my real problem:
We have a set of applications that target Windows XP up to Windows 8.1, and Windows Server 2008 & 2012 (32-bit/64-bit version support too). Previously we did nothing in code to make sure you were running on these platforms.
We made a change to use the IsWindowsXPOrGreater function call when creating our set of Windows API wrapper classes. If this call returns false we throw an exception, that will be caught and cause an error message to display.
However, the error message is created by jumping through a set of Windows API calls. According to MSDN most of the calls require Windows 2000 or later, although a few are Windows XP or later.
After implementing the unit tests and mod I developed doubts that the code will actually run if we actually ran the software on anything prior to Windows XP - because either the IsWindowsXPOrGreater function requires Windows 2000 or later or the error message module will fail on their calls to the Windows API.
I have shown my colleagues that if I force IsWindowsXPOrGreater to give a false return, an exception is raised but we end up in an endless loop because our error message module raises another instance of the exception, which we pick up again to try to use the Windows API and so on.
Question
If IsWindowsXPOrGreater returns false which Windows API calls are safe to use on any 32-bit installation of a Windows operating system?
MSDN seems to show a minimum of Windows 2000 or Windows XP for most Windows API functions. Is there any documentation for the earlier versions of User32.dll, Kernel32.dll etc?
My Current Workaround
We have since changed our code to catch a new LowerThanWindowsXPException - which will use a variant wrapper for MessageBox to display a simple message before terminating the app. This variant does not check the windows version, and is based on some legacy Visual Basic code we have lying around. This worked on Windows 95 although we have no way of checking that now.
In the future we will be using IsWindows7OrGreater for additional Windows API calls and in these cases we will raise a LowerThanWindows7Exception - which we can catch and treat differently (such as use our Windows XP API calls to display an error message or fall back on some alternative functionality).
Aucun commentaire:
Enregistrer un commentaire