Environment Class (Microsoft.Office.InfoPath)

Provides properties to determine what runtime environment was used to open the form template.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

Syntax

'Declaration
Public MustInherit Class Environment
'Usage
Dim instance As Environment
public abstract class Environment

Remarks

Use the Environment property of the Application class to determine which runtime environment and program was used to open the form template for editing.

The Environment class provides the IsBrowser and IsMobile properties which enable you to determine what editing environment was used to open a form template. If both properties return false, the form template was opened in Microsoft Office InfoPath 2007. If either property returns true, the form template was opened from Microsoft Office Forms Server 2007 or from an appropriately configured document library on Microsoft Office SharePoint Server 2007 running InfoPath Forms Services in the program for the corresponding property: a Web browser (IsBrowser property) or a mobile browser (IsMobile property).

Example

In the following example, a basic pattern is shown for checking the values of IsBrowser and IsMobile properties to conditionally run code depending on which environment and program was used to open the form.

if (this.Application.Environment.IsBrowser)
{
   // Code to run if form is open in a Web browser.
}

else if (this.Application.Environment.IsMobile)
{
   // Code to run if form is open in a mobile browser.
}
else
{
   // Code to run if form is open in the InfoPath application.
}
If (Me.Application.Environment.IsBrowser) Then
   ' Code to run if form is open in a Web browser.
ElseIf (Me.Application.Environment.IsMobile) Then
   ' Code to run if form is open in a mobile browser.
Else
   ' Code to run if form is open in the InfoPath application.
End If

Inheritance Hierarchy

System.Object
  Microsoft.Office.InfoPath.Environment

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Environment Members
Microsoft.Office.InfoPath Namespace