Title: How to detect Windows Vista ?
Question: Some of my "old" delphi applications cannot run properly under Windows Vista (cause using some ActiveX...) even with the Windows XP Compatibility mode actived. By using the GetVersionEx function, I cannot detect Vista version, so how can I do to detect Vista even in Compatibility mode ?
Answer:
What I've found on MSDN network (http://msdn2.microsoft.com/en-us/library/ms724358.aspx) is that under Windows Vista, the Kernel32.dll has a new function named GetProductInfo. This one is only available under Windows Vista.
So, by testing its existence you could know if your application runs under Vista even with the Compatibility mode actived (WinXP or other...).
//---------------------------------------------------------------------
interface
...
function IsHiddenVista: Boolean;
implementation
uses Windows, System;
function IsHiddenVista: Boolean;
var
pFunction: Pointer;
begin
pFunction := GetProcAddress(GetModuleHandle('KERNEL32.DLL'), 'GetProductInfo');
Result := Assigned(pFunction);
end;