Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

簡介

Windows Installer 提供 Api,讓使用者可以查詢 Windows 安裝程式資料庫,以尋找特定產品的目前狀態。 每個產品都是由其產品代碼以唯一的方式來識別,這是 GUID。 本文提供的程式碼範例示範如何使用其產品程式碼,以程式設計方式檢查是否存在 Windows 安裝程式產品。

其他相關資訊

從 Visual c + + 呼叫 API

下列範例說明如何在 Visual c + + 中呼叫MsiGetProductInfoExW ()方法,以偵測特定產品的目前狀態。 該產品是由其獨特的產品程式碼 GUID 所指定。

TCHAR szVersion[20];DWORD cchVersion = 20;BOOL fInstalled = (ERROR_SUCCESS == MsiGetProductInfoEx (TEXT("{ProductCode}"), NULL, MSIINSTALLCONTEXT_MACHINE, INSTALLPROPERTY_VERSIONSTRING, szVersion, &cchVersion));

在這個程式碼範例片段中,fInstalled Boolean 變數會包含 TRUE 或 FALSE 值,這取決於指定的產品是否已安裝或尚未安裝。

從 VBScript 呼叫 API

下列範例說明如何在 Microsoft Visual Basic 腳本中,呼叫WindowsInstaller物件的ProductInfo ()方法,以偵測特定產品的目前狀態。 該產品是由其獨特的產品程式碼 GUID 所指定。

 Dim msi : Set msi = CreateObject("WindowsInstaller.Installer")On Error Resume NextDim version : version = msi.ProductInfo("{ProductCode}", "VersionString")Dim installed : installed = ( Err.Number = 0 )

在這個程式碼範例片段中,已安裝的變數會包含0或1值,視所指定的產品是否已安裝或尚未安裝而定。注意: 在這兩個範例中傳遞給函數的ProductCode屬性都包含引號內的大括弧({})。 如需 Windows 安裝程式的詳細資訊,請造訪下列 Microsoft Windows Installer MSDN 網頁:

http://msdn.microsoft.com/en-us/library/aa367449(VS.85).aspx如需如何取得電腦最新版本 Windows 安裝程式的詳細資訊,請流覽下列 Microsoft 網頁:

http://www.microsoft.com/download/details.aspx?familyid=5A58B56F-60B6-4412-95B9-54D056D6F9F4&displaylang=en 如需詳細資訊,請流覽下列 Microsoft 網頁:

關於「適用于」區段的注意事項除了「適用于」區段中所列的產品之外,本文中的資訊也適用于下列產品:

  • Windows Installer 4。0

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×