From Xojo Documentation

Constant As Boolean

aBoolean = TargetWindows

New in 2015r4

Used to indicate that the code has been compiled for or is running on Microsoft Windows.


result = TargetWindows

Part Type Description
result Boolean Returns True if you are compiling Windows code.


TargetWindows indicates that your application compiled or running on Windows (using the Win32 platform, as opposed to something like .NET). This is True for both 64-bit and 32-bit apps. If you need to detect whether an app is 32-bit or 64-bit, use the appropriate constants: Target32Bit and Target64Bit.

Sample Code

Use this code to follow a different code path when running on Windows:

If TargetWindows Then
// Do some Windows-specific stuff here
End If

Using conditional compilation with the TargetWindows constant means that this code will only appear in Windows builds:

#If TargetWindows Then
// Use Registry to save preferences

This example function can be used to detect if you application is building for a 64-bit version of Windows:

#If TargetWindows Then
#If Target64Bit
// Building for 64-bit Windows
// Building for 32-bit Windows

See Also

DebugBuild, XojoVersion, XojoVersionString, TargetBigEndian, TargetDesktop, TargetLinux, TargetLittleEndian, TargetMachO, TargetMacOS, TargetWeb, TargetX86, Target32Bit, Target64Bit constants; #If...#Endif statement.