From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Constant As Boolean

aBoolean = TargetWin32

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


result = TargetWin32

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


TargetWin32 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 TargetWin32 Then
// Do some Windows-specific stuff here
End If

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

#If TargetWin32 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 TargetWin32
#If Target64Bit
// Building for 64-bit Windows
// Building for 32-bit Windows

See Also

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