Environment.UserInteractive 属性

定义

获取一个值,用以指示当前进程是否在用户交互模式中运行。

public:
 static property bool UserInteractive { bool get(); };
public static bool UserInteractive { get; }
static member UserInteractive : bool
Public Shared ReadOnly Property UserInteractive As Boolean

属性值

如果当前进程在用户交互模式中运行,则为true ;否则为 false

示例

以下示例显示当前进程是否在用户交互模式下运行。

// Sample for the Environment::UserInteractive property
using namespace System;
int main()
{
   Console::WriteLine();
   Console::WriteLine( "UserInteractive: {0}", Environment::UserInteractive );
}

/*
This example produces the following results:

UserInteractive: True
*/
// Sample for the Environment.UserInteractive property
using System;

class Sample
{
    public static void Main()
    {
    Console.WriteLine();
    Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive);
    }
}
/*
This example produces the following results:

UserInteractive: True
*/
// Sample for the Environment.UserInteractive property
open System

printfn $"\nUserInteractive: {Environment.UserInteractive}"

// This example produces the following results:
//     UserInteractive: True
' Sample for the Environment.UserInteractive property
Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive)
   End Sub
End Class
'
'This example produces the following results:
'
'UserInteractive: True
'

注解

属性 UserInteractive 报告 false 在没有用户界面的情况下运行的 Windows 进程或 IIS 等服务。 如果此属性为 false,则不显示模式对话框或消息框,因为没有可供用户与之交互的图形用户界面。

适用于

另请参阅