OperatingSystem.ServicePack 屬性

定義

取得這個 OperatingSystem 物件所代表的 Service Pack 版本。

public:
 property System::String ^ ServicePack { System::String ^ get(); };
public string ServicePack { get; }
member this.ServicePack : string
Public ReadOnly Property ServicePack As String

屬性值

如果支援並至少安裝一個 Service Pack,則為 Service Pack 版本,否則為空字串 ("")。

範例

下列程式碼範例示範 ServicePack 屬性。

// This example demonstrates the OperatingSystem.ServicePack property.
using namespace System;
int main()
{
   OperatingSystem^ os = Environment::OSVersion;
   String^ sp = os->ServicePack;
   Console::WriteLine( "Service pack version = \"{0}\"", sp );
}

/*
This example produces the following results:

Service pack version = "Service Pack 1"

*/
// This example demonstrates the OperatingSystem.ServicePack property.
using System;

class Sample
{
    public static void Main()
    {
    OperatingSystem os = Environment.OSVersion;
    String sp = os.ServicePack;
    Console.WriteLine("Service pack version = \"{0}\"", sp);
    }
}
/*
This example produces the following results:

Service pack version = "Service Pack 1"

*/
// This example demonstrates the OperatingSystem.ServicePack property.
open System

let os = Environment.OSVersion
let sp = os.ServicePack
printfn $"Service pack version = \"{sp}\""
// This example produces the following results:
//     Service pack version = "Service Pack 1"
' This example demonstrates the OperatingSystem.ServicePack property.
Class Sample
   Public Shared Sub Main()
      Dim os As OperatingSystem = Environment.OSVersion
      Console.WriteLine("Service pack version = ""{0}""", os.ServicePack)
   End Sub
End Class
'
'This example produces the following results:
'
'Service pack version = "Service Pack 1"
'

備註

Service Pack 可用來發佈其安裝所在作業系統的軟體更新。 不過,並非所有作業系統都會使用 Service Pack。

如果可用,Service Pack 版本已正確格式化以顯示。

適用於

另請參閱