programming.torensma.net: Code Snippets

Am I running as a 32 or 64-bit application?

Here’s an easy way to determine if a .NET application is running as either 32 or 64-bit  application.

VB

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  If IntPtr.Size = 8 Then
    Response.Write("64-bit")
  ElseIf IntPtr.Size = 4 Then
    Response.Write("32-bit")
  End If
End Sub

C#

protected void Page_Load(object sender, EventArgs e)
{
  if (IntPtr.Size == 8)
  {
    Response.Write("64-bit");
  }
  else if (IntPtr.Size == 4)
  {
    Response.Write("32-bit");
  }
}

You can follow any responses to this entry through the RSS 2.0 feed.