-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from learn-more/fix_filetime
fix: Properly display FILETIME in the summary view
- Loading branch information
Showing
4 changed files
with
102 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace LessMsi.Gui.Extensions | ||
{ | ||
internal static class MsiNativeMethods | ||
{ | ||
[DllImport("msi.dll", CharSet = CharSet.Unicode, EntryPoint = "MsiSummaryInfoGetPropertyW", ExactSpelling = true)] | ||
internal static extern uint MsiSummaryInfoGetProperty(IntPtr summaryInfo, int property, out uint dataType, out int integerValue, ref System.Runtime.InteropServices.ComTypes.FILETIME fileTimeValue, StringBuilder stringValueBuf, ref int stringValueBufSize); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/LessMsi.Gui/Extensions/SummaryInformationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Microsoft.Tools.WindowsInstallerXml.Msi; | ||
using System; | ||
using System.Text; | ||
|
||
namespace LessMsi.Gui.Extensions | ||
{ | ||
public static class SummaryInformationExtensions | ||
{ | ||
/// <summary> | ||
/// There is a bug in Wix where it does not correctly return data with the FILETIME type. | ||
/// This extension method manually retrieves the value, and converts it to a DateTime. | ||
/// </summary> | ||
public static object GetPropertyFileTime(this SummaryInformation summaryInfo, int index) | ||
{ | ||
uint iDataType; | ||
int integerValue, stringValueBufSize = 0; | ||
System.Runtime.InteropServices.ComTypes.FILETIME fileTimeValue = new System.Runtime.InteropServices.ComTypes.FILETIME(); | ||
StringBuilder stringValueBuf = new StringBuilder(); | ||
|
||
uint result = MsiNativeMethods.MsiSummaryInfoGetProperty(summaryInfo.InternalHandle, index, | ||
out iDataType, out integerValue, ref fileTimeValue, stringValueBuf, ref stringValueBufSize); | ||
|
||
if (result != 0) | ||
{ | ||
throw new ArgumentNullException(); | ||
} | ||
|
||
switch ((Model.VT)iDataType) | ||
{ | ||
case Model.VT.EMPTY: | ||
return string.Empty; | ||
case Model.VT.FILETIME: | ||
return DateTime.FromFileTime((((long)fileTimeValue.dwHighDateTime) << 32) | ((uint)fileTimeValue.dwLowDateTime)); | ||
default: | ||
throw new ArgumentNullException(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters