Constant

TargetWindows


Description

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

Usage

result = TargetWindows

Part

Type

Description

result

Boolean

Returns True if you are compiling Windows code.

Notes

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
#Endif

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
  #Else
    ' Building for 32-bit Windows
  #Endif
#EndIf

Compatibility

All project types on all supported operating systems.