diff options
Diffstat (limited to 'src/test/burn/WixTestTools/MsiUtilities.cs')
-rw-r--r-- | src/test/burn/WixTestTools/MsiUtilities.cs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/burn/WixTestTools/MsiUtilities.cs b/src/test/burn/WixTestTools/MsiUtilities.cs new file mode 100644 index 00000000..4c7d1601 --- /dev/null +++ b/src/test/burn/WixTestTools/MsiUtilities.cs | |||
@@ -0,0 +1,47 @@ | |||
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 | |||
3 | namespace WixTestTools | ||
4 | { | ||
5 | using System; | ||
6 | using WixToolset.Dtf.WindowsInstaller; | ||
7 | |||
8 | public class MsiUtilities | ||
9 | { | ||
10 | /// <summary> | ||
11 | /// Return true if it finds the given productcode in system otherwise it returns false | ||
12 | /// </summary> | ||
13 | /// <param name="prodCode"></param> | ||
14 | /// <returns></returns> | ||
15 | public static bool IsProductInstalled(string prodCode) | ||
16 | { | ||
17 | //look in all user's products (both per-machine and per-user) | ||
18 | foreach (ProductInstallation product in ProductInstallation.GetProducts(null, "s-1-1-0", UserContexts.All)) | ||
19 | { | ||
20 | if (product.ProductCode == prodCode) | ||
21 | { | ||
22 | return true; | ||
23 | } | ||
24 | } | ||
25 | return false; | ||
26 | } | ||
27 | |||
28 | /// <summary> | ||
29 | /// Return true if it finds the given productcode in system with the specified version otherwise it returns false | ||
30 | /// </summary> | ||
31 | /// <param name="prodCode"></param> | ||
32 | /// <param name="prodVersion"></param> | ||
33 | /// <returns></returns> | ||
34 | public static bool IsProductInstalledWithVersion(string prodCode, Version prodVersion) | ||
35 | { | ||
36 | //look in all user's products (both per-machine and per-user) | ||
37 | foreach (ProductInstallation product in ProductInstallation.GetProducts(null, "s-1-1-0", UserContexts.All)) | ||
38 | { | ||
39 | if (product.ProductCode == prodCode && product.ProductVersion == prodVersion) | ||
40 | { | ||
41 | return true; | ||
42 | } | ||
43 | } | ||
44 | return false; | ||
45 | } | ||
46 | } | ||
47 | } | ||