Constant

# TargetWindows

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

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

## Usage

``` xojo
result = TargetWindows
```

| Part   | Type                               | Description                                                           |
|--------|------------------------------------|-----------------------------------------------------------------------|
| result | `Boolean</api/data_types/boolean>` | Returns `True</api/language/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</api/compiler_directives/target32bit>` and `Target64Bit</api/compiler_directives/target64bit>`.

## Sample code

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

``` xojo
If TargetWindows Then
  ' Do some Windows-specific stuff here
End If
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Using conditional compilation with the <span class="title-ref">TargetWindows</span> constant means that this code will only appear in Windows builds:

``` xojo
#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:

``` xojo
#If TargetWindows Then
  #If Target64Bit
    ' Building for 64-bit Windows
  #Else
    ' Building for 32-bit Windows
  #Endif
#EndIf
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`DebugBuild</api/compiler_directives/debugbuild>`, `XojoVersion</api/language/xojoversion>`, `XojoVersionString</api/language/xojoversionstring>`, `TargetAndroid</api/compiler_directives/targetandroid>`, `TargetBigEndian</api/compiler_directives/targetbigendian>`, `TargetDesktop</api/compiler_directives/targetdesktop>`, `TargetLinux</api/compiler_directives/targetlinux>`, `TargetLittleEndian</api/compiler_directives/targetlittleendian>`, `TargetMachO</api/compiler_directives/targetmacho>`, `TargetMacOS</api/compiler_directives/targetmacos>`, `TargetMobile</api/compiler_directives/targetmobile>`, `TargetWeb</api/compiler_directives/targetweb>`, `TargetX86</api/compiler_directives/targetx86>`, `Target32Bit</api/compiler_directives/target32bit>`, `Target64Bit</api/compiler_directives/target64bit>` constants; `＃If...＃Endif</api/compiler_directives/if...endif>` statement.

</div>
