擷取本地電腦作業系統的產品類型,並將該類型映射到指定作業系統支援的產品類型。
若要取得需求區中指定最低支援作業系統版本之前的 Windows 版本產品類型資訊,請使用 GetVersionEx 函式。 你也可以使用 Win32_OperatingSystem WMI 類別的 OperatingSystemSKU 屬性。
句法
BOOL GetProductInfo(
[in] DWORD dwOSMajorVersion,
[in] DWORD dwOSMinorVersion,
[in] DWORD dwSpMajorVersion,
[in] DWORD dwSpMinorVersion,
[out] PDWORD pdwReturnedProductType
);
Parameters
[in] dwOSMajorVersion
作業系統的主要版本號碼。 最低值是6。
dwOSMajorVersion、dwOSMinorVersion、dwSpMajorVersion 與 dwSpMinorVersion 參數的組合,描述了應用程式的最大目標作業系統版本。 例如,Windows Vista 和 Windows Server 2008 是版本 6.0.0.0,而 Windows 7 和 Windows Server 2008 R2 則是版本 6.1.0.0。 所有基於 Windows 10 的版本都會以 6.3 版本列出。
[in] dwOSMinorVersion
作業系統的次要版本號碼。 最低值為0。
[in] dwSpMajorVersion
作業系統服務包的主要版本號。 最低值為0。
[in] dwSpMinorVersion
作業系統服務包的次要版本號。 最低值為0。
[out] pdwReturnedProductType
產品類型。 這個參數不能 NULL。 若指定的作業系統小於目前作業系統,這些資訊會映射到指定作業系統所支援的類型。 若指定的作業系統大於最高支援的作業系統,則此資訊會映射到目前作業系統所支援的類型。
此參數可為以下數值之一(以下部分產品可能不支援)。
| Value | Meaning |
|---|---|
|
Business |
|
商業N |
|
HPC 版 |
|
伺服器 Hyper Core V |
|
Windows 10 家庭版 |
|
Windows RT |
|
Windows 10 家庭版中國版 |
|
Windows 10 Home N |
|
Windows 10 家庭單語言 |
|
伺服器資料中心(評估安裝) |
|
伺服器資料中心,Semi-Annual 通道(核心安裝) |
|
伺服器標準,Semi-Annual 通道(核心安裝) |
|
Windows Server Datacenter Edition(Nano Server 安裝) |
|
伺服器資料中心(完整安裝。對於安裝 Windows Server 2012 及更新版本的 Server Core,請使用「判斷 Server Core 是否正在執行」的方法。) |
|
Windows Server Datacenter: Azure Edition |
|
Server Datacenter(核心安裝,Windows Server 2008 R2 及更早版本) |
|
沒有 Hyper-V 的伺服器資料中心(核心安裝) |
|
沒有 Hyper-V 的伺服器資料中心(完整安裝) |
|
Windows Server Datacenter Edition(Server Core 安裝) |
|
Windows 10 教育 |
|
Windows 10 教育版 N |
|
Windows 嵌入式產業 |
|
Windows 10 企業版 |
|
Windows 10 Enterprise E |
|
Windows 10 企業版評估 |
|
Windows 10 Enterprise N |
|
Windows 10 Enterprise N 評估 |
|
Windows 10 Enterprise 2015 LTSB |
|
Windows 10 Enterprise 2015 LTSB 評估 |
|
Windows 10 Enterprise 2015 LTSB N |
|
Windows 10 Enterprise 2015 LTSB N 評估 |
|
Server Enterprise(完整安裝) |
|
Server Enterprise(核心安裝) |
|
沒有 Hyper-V 的 Server Enterprise(核心安裝) |
|
基於 Itanium 系統的 Server Enterprise |
|
Server Enterprise 無 Hyper-V(完整安裝) |
|
Windows Essential Server 解決方案 附加 |
|
Windows Essential Server 解決方案 額外 SVC |
|
Windows Essential Server 解決方案管理 |
|
Windows Essential Server 解決方案管理 SVC |
|
家庭基礎 |
|
不支援 |
|
家庭 Basic N |
|
家庭保費 |
|
不支援 |
|
Home Premium N |
|
Windows Home Server 2011 |
|
Windows Storage Server 2008 R2 Essentials |
|
Microsoft Hyper-V伺服器 |
|
Windows 嵌入式手持型 |
|
Windows IoT Enterprise |
|
Windows IoT Enterprise LTSC |
|
Windows 10 IoT Core |
|
Windows 10 IoT Core Commercial |
|
Windows Essential 商業伺服器管理伺服器 |
|
Windows Essential 商業伺服器訊息伺服器 |
|
Windows Essential 商業伺服器安全伺服器 |
|
Windows 10 Mobile |
|
Windows 10 行動企業版 |
|
Windows MultiPoint Server Premium(完整安裝) |
|
Windows 多點伺服器標準(完整安裝) |
|
Windows 10 團隊 |
|
Windows 10 專業版教育 |
|
Windows 10 Pro 工作站版 |
|
Windows 10 Pro 工作站 N |
|
Windows 10 專業版 |
|
不支援 |
|
Windows 10 Pro N |
|
媒體中心專業 |
|
Windows Small Business Server 2011 精選 |
|
SB Solutions EM 伺服器 |
|
SB 解決方案伺服器 |
|
SB Solutions EM 伺服器 |
|
Windows Server 2008 for Windows Essential Server 解決方案 |
|
Windows Server 2008 年無 Hyper-V Windows Essential Server Solutions |
|
伺服器基金會 |
|
Windows 10 Enterprise 虛擬桌面版 |
|
Windows Small Business Server |
|
小型企業伺服器高級服務 |
|
小型企業伺服器高級版(核心安裝) |
|
Windows 多點伺服器 |
|
伺服器標準(評估安裝) |
|
Windows Server 標準版(Nano Server 安裝) |
|
伺服器標準(完整安裝。對於安裝 Windows Server 2012 及更新版本的 Server Core,請使用「判斷 Server Core 是否正在執行」的方法。) |
|
伺服器標準(核心安裝,Windows Server 2008 R2 及更早版本) |
|
伺服器標準無 Hyper-V(核心安裝) |
|
伺服器標準無 Hyper-V |
|
伺服器解決方案高級版 |
|
Server Solutions Premium(核心安裝) |
|
Windows Server 標準版(Server Core 安裝) |
|
起始器 |
|
不支援 |
|
起始N |
|
儲存伺服器企業級 |
|
儲存伺服器企業版(核心安裝) |
|
儲存伺服器快運 |
|
Storage Server Express(核心安裝) |
|
儲存伺服器標準(評估安裝) |
|
儲存伺服器標準 |
|
儲存伺服器標準(核心安裝) |
|
儲存伺服器工作組(評估安裝) |
|
儲存伺服器工作組 |
|
儲存伺服器工作組(核心安裝) |
|
Windows 薄型電腦 |
|
終極賽 |
|
不支援 |
|
終極N |
|
未知產品 |
|
網頁伺服器(完整安裝) |
|
網頁伺服器(核心安裝) |
返回值
如果函式成功,傳回值會是非零值。
如果函數失敗,則傳回值為零。 若其中一個輸入參數無效,此函式即告失敗。
備註
要偵測是否安裝了伺服器角色或功能,請使用 伺服器功能 WMI 提供者。
後續版本的 Windows 會將其支援的產品類型映射到每個先前支援的 Windows 版本所支援的產品類型集合,回到版本 6.0.0.0。 因此,對任一這些數值進行等性測試的應用程式,即使新增產品類型,未來版本仍能持續運作。
PRODUCT_*_SERVER_CORE 值在 Windows Server 2012 及之後不會回傳。 例如,基礎伺服器版本 Server Datacenter 用於建置兩種不同的安裝選項:「完整伺服器」與「核心伺服器」。 有了Windows Server 2012,GetProductInfo 無論安裝時使用哪種選項,都會回傳PRODUCT_DATACENTER。 如前所述,對於安裝 Windows Server 2012 及更新版本的 Server Core,請使用「判斷 Server Core 是否正在執行」的方法。
下表顯示 6.1.0.0 引入的產品類型,以及如果在 6.1.0.0 系統上以 6.0.0.0 版本呼叫 GetProductInfo ,這些類型會對應到哪些類型。
| 6.1.0.0 新增功能 | 值回傳為 6.0.0.0 |
|---|---|
| PRODUCT_PROFESSIONAL | PRODUCT_BUSINESS |
| PRODUCT_PROFESSIONAL_N | PRODUCT_BUSINESS_N |
| PRODUCT_STARTER_N | PRODUCT_STARTER |
若要編譯使用此函式的應用程式,請將_WIN32_WINNT定義為 0x0600 或更高版本。 如需詳細資訊,請參閱 使用 Windows 標頭。
Examples
舉例來說,請參見 「取得系統版本」。
Requirements
| Requirement | Value |
|---|---|
| 最低支援的用戶端 | Windows Vista [僅限傳統型應用程式] |
| 支援的最低伺服器 | Windows Server 2008 [僅限傳統型應用程式] |
| 目標平臺 | Windows |
| Header | sysinfoapi.h (包括 Windows.h) |
| Library | 內核 32.lib |
| DLL | Kernel32.dll |