-2

Porting to XE2 and I've got a line IsWinNT that compiled in 7 and Delphi 2009 and never gave us any guff before.

I'm not sure what the purpose of such a function is, but was it removed or moved?

and what is a comparable function?


My bad, it was in Virtual Trees har. Sorry guys -1 for me. Free +1's on the house

Peter Turner
  • 11,199
  • 10
  • 68
  • 109

3 Answers3

6

I don't know such function, but you can use this code

if Win32Platform = VER_PLATFORM_WIN32_NT then 

FYI Delphi XE2 only runs on WinNT based systems

RRUZ
  • 134,889
  • 20
  • 356
  • 483
5

In Delphi 2009, there is no IsWinNT function. In addition, there is no Windows API function named like that. Most likely you are confused: Perhaps IsWinNT was part of some 3rd-party library that you used?

Anyhow, if you are only targeting the Windows platform, then you can implement the function as

function IsWinNT: boolean;
begin
  result := true;
end;

since every Windows version since (and including) XP has been based on NT.

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
  • 1
    Windows 95, 98 and ME were all released after Windows NT 3.1 – David Heffernan Dec 01 '11 at 22:20
  • @Joe White: That is incorrect. Windows ME was released several months after Windows 2000 was released. – Andreas Rejbrand Dec 01 '11 at 22:25
  • But 95,98 and ME were not based on NT technology. – LU RD Dec 01 '11 at 23:31
  • @LURD that is indeed the case which makes Andreas's function a bit odd in my view. Maybe I'm missing some nuance. – David Heffernan Dec 01 '11 at 23:55
  • Can executables compiled with Delphi 2009 even run on 98 or ME anymore, even with MSLU? – afrazier Dec 02 '11 at 00:49
  • @David: I think that an application compiled with a modern version of Delphi (such as 2009, or XE) cannot be run on Windows 9x. Hence, `IsWinNT` should return `true` in every case where the function can be executed. – Andreas Rejbrand Dec 02 '11 at 06:16
  • @andreas that's the official line but I have a hunch that if you eschew the vcl then you can still produce 9x apps but that's just nitpicking – David Heffernan Dec 02 '11 at 07:22
  • @David: I just tried to run an empty standard VCL app and an empty console application made in Delphi 2009 under Windows 95 with IE4 installed. Neither worked. – Andreas Rejbrand Dec 02 '11 at 10:52
  • @Andreas I can see why the VCL app would fail (Unicode APIs). Do you know why the console app failed? And how on earth did you get hold of win95 box??!!! – David Heffernan Dec 02 '11 at 10:53
  • 1
    @David: [Two error messages](http://privat.rejbrand.se/w95ie4delphi2009.png) are displayed. (English: "The given device, path, or file could not be accessed." and "Error at application startup. The file %s requires a newer version of Windows. Upgrade Windows.") I have an old HP Vectra VE 200 with Windows 95, and, in addition, I have Windows 95 installed on my main computer inside VirtualBox. – Andreas Rejbrand Dec 02 '11 at 11:15
  • @David, yeah, I didn't mark this as accepted for the wisdom of the function, which would certainly need some ifdefs if I want to cross compile with an older Delphi or anything like that, but he was dead on about isWinNT being part of a 3rd party library. – Peter Turner Dec 02 '11 at 22:46
3

I can't find that function in any of my Delphi's (D6, D2010, DXE2). I would test for NT like this:

Win32Platform = VER_PLATFORM_WIN32_NT

This test is a little redundant on XE2 since it no longer supports targetting non-NT versions of Windows. I've not actually tried running an XE2 produced executable on Win9x lately so I don't know whether or not it fails when you do so.

In XE2 you can now make use of TOSVersion. For example, to check that you are running on Windows XP or up you would simply do:

if (TOSVersion.Platform=pfWindows) and (TOSVersion.Check(5, 1)) then
  ...
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490