aboutsummaryrefslogtreecommitdiff
path: root/src/WixTestTools/MsiUtilities.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixTestTools/MsiUtilities.cs')
-rw-r--r--src/WixTestTools/MsiUtilities.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/WixTestTools/MsiUtilities.cs b/src/WixTestTools/MsiUtilities.cs
new file mode 100644
index 00000000..2a848938
--- /dev/null
+++ b/src/WixTestTools/MsiUtilities.cs
@@ -0,0 +1,27 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixTestTools
4{
5 using WixToolset.Dtf.WindowsInstaller;
6
7 public class MsiUtilities
8 {
9 /// <summary>
10 /// Return true if it finds the given productcode in system otherwise it returns false
11 /// </summary>
12 /// <param name="prodCode"></param>
13 /// <returns></returns>
14 public static bool IsProductInstalled(string prodCode)
15 {
16 //look in all user's products (both per-machine and per-user)
17 foreach (ProductInstallation product in ProductInstallation.GetProducts(null, "s-1-1-0", UserContexts.All))
18 {
19 if (product.ProductCode == prodCode)
20 {
21 return true;
22 }
23 }
24 return false;
25 }
26 }
27}