Virtual Pascal

Classic Object Pascal for free


  versionInfo.dwOSVersionInfoSize := SizeOf(versionInfo);
  VMajor:= versionInfo.dwMajorVersion;

should return 6 for Windows 7 but it returns the same 5 as it does for XP.

Anyone know a reliable way to detect Windows 7 with VP?

Views: 525

Reply to This

Replies to This Discussion

Hi !

Normally GetVersionEx should work but the version value may be different if the compatibility mode is activated.

Maybe you are running your program through VP and VP is set in XP-compatiblility mode under Win 7 ?



VP is running on a virtual machine, app is running on Win 7 and yes if compatibility mode is activated for the app then GetVersionEx will return that mode.

But is there a way of seeing past that to see if the OS is Win 7 even if a compatibility mode is being used?

Sorry should have worded the original question better.



Not via getversionex, but maybe you could try to read out the registry(though this is "NT" only I guess):


You can read the OS version from the Registry key also

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

This key has a string called "CurrentVersion"


You can also use the GetFileVersionInfo function on a system file such as kernel32.dll. There is an example at


Thanks guys, GetFileVersionInfo would appear to be the reliable way to do it.


© 2022   Created by Allan Mertner.   Powered by

Report an Issue  |  Terms of Service