ServiceInstaller.Description 属性

定义

获取或设置服务的说明。

public:
 property System::String ^ Description { System::String ^ get(); void set(System::String ^ value); };
[System.Runtime.InteropServices.ComVisible(false)]
[System.ServiceProcess.ServiceProcessDescription("ServiceInstallerDescription")]
public string Description { get; set; }
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.ServiceProcess.ServiceProcessDescription("ServiceInstallerDescription")>]
member this.Description : string with get, set
Public Property Description As String

属性值

String

服务的说明。 默认值为空字符串("")。

属性

示例

下面的代码示例为新的服务应用程序设置Windows属性。 该示例设置服务名称以及显示名称和说明。 为服务分配安装属性后,该示例会将 ServiceInstaller 对象添加到 Installers 集合。

simpleServiceProcessInstaller = new ServiceProcessInstaller();
simpleServiceInstaller = new ServiceInstaller();

// Set the account properties for the service process.
simpleServiceProcessInstaller.Account = ServiceAccount.LocalService;

// Set the installation properties for the service.
// The ServiceInstaller.ServiceName must match the
// ServiceBase.ServiceName set in the service
// implementation that is installed by this installer.
simpleServiceInstaller.ServiceName = "SimpleService";

simpleServiceInstaller.DisplayName = "Simple Service";
simpleServiceInstaller.Description = "A simple service that runs on the local computer.";
simpleServiceInstaller.StartType = ServiceStartMode.Manual;

// Add the installers to the Installer collection.
Installers.Add(simpleServiceInstaller);
Installers.Add(simpleServiceProcessInstaller);
' Start the service.
Protected Overrides Sub OnStart(ByVal args() As String) 
    ' Start a separate thread that does the actual work.
    If workerThread Is Nothing OrElse(workerThread.ThreadState And System.Threading.ThreadState.Unstarted Or System.Threading.ThreadState.Stopped) <> 0 Then
        Trace.WriteLine(DateTime.Now.ToLongTimeString() + " - Starting the service worker thread.", "OnStart")
        
        workerThread = New Thread(New ThreadStart(AddressOf ServiceWorkerMethod))
        workerThread.Start()
    End If
    If Not (workerThread Is Nothing) Then
        Trace.WriteLine(DateTime.Now.ToLongTimeString() + " - Worker thread state = " + workerThread.ThreadState.ToString(), "OnStart")
    End If

End Sub

注解

使用 Description 属性向用户描述已安装服务的用途。 用户可以在显示已安装服务详细信息的应用程序中查看服务说明。

例如,使用 Windows XP,可以使用服务控制命令行实用工具 (Sc.exe) 查看服务说明,也可以查看计算机管理控制台的"服务"节点内的 服务说明

适用于

另请参阅