Skip to content

Commit

Permalink
Added support for checking the presence of a Windows QFE update.
Browse files Browse the repository at this point in the history
Requires Windows Vista or later as it uses WMI to check for the presence of the QFE.
  • Loading branch information
Chris Crowther committed Sep 29, 2020
1 parent 3656750 commit 99f9f34
Show file tree
Hide file tree
Showing 17 changed files with 1,040 additions and 803 deletions.
49 changes: 34 additions & 15 deletions InstallerEditor/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class MainForm : System.Windows.Forms.Form, IMRUClient
private MenuItem mnAddCommandComponent;
private MenuItem mnAddInstalledCheckRegistry;
private MenuItem mnAddInstalledCheckFile;
private MenuItem mnAddInstalledCheckWindowsUpdate;
private MenuItem mnAddDownloadDialog;
private MenuItem mnSaveAs;
private MenuItem mnEditWithNotepad;
Expand Down Expand Up @@ -166,6 +167,7 @@ private void InitializeComponent()
this.mnAddInstalledCheckDirectory = new System.Windows.Forms.MenuItem();
this.mnAddInstalledCheckOperator = new System.Windows.Forms.MenuItem();
this.mnAddInstalledCheckProduct = new System.Windows.Forms.MenuItem();
this.mnAddInstalledCheckWindowsUpdate = new System.Windows.Forms.MenuItem();
this.menuDownload = new System.Windows.Forms.MenuItem();
this.mnAddDownloadDialog = new System.Windows.Forms.MenuItem();
this.mnAddDownloadFile = new System.Windows.Forms.MenuItem();
Expand All @@ -178,6 +180,7 @@ private void InitializeComponent()
this.mnAddCheckboxControl = new System.Windows.Forms.MenuItem();
this.mnAddBrowseControl = new System.Windows.Forms.MenuItem();
this.mnAddHyperlinkControl = new System.Windows.Forms.MenuItem();
this.mnAddImageControl = new System.Windows.Forms.MenuItem();
this.menuSep4 = new System.Windows.Forms.MenuItem();
this.mnAddLicenseAgreement = new System.Windows.Forms.MenuItem();
this.mnMove = new System.Windows.Forms.MenuItem();
Expand Down Expand Up @@ -207,7 +210,7 @@ private void InitializeComponent()
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.txtComment = new System.Windows.Forms.TextBox();
this.mnAddImageControl = new System.Windows.Forms.MenuItem();
((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
this.mainSplitContainer.Panel1.SuspendLayout();
this.mainSplitContainer.Panel2.SuspendLayout();
this.mainSplitContainer.SuspendLayout();
Expand Down Expand Up @@ -441,7 +444,8 @@ private void InitializeComponent()
this.mnAddInstalledCheckFile,
this.mnAddInstalledCheckDirectory,
this.mnAddInstalledCheckOperator,
this.mnAddInstalledCheckProduct});
this.mnAddInstalledCheckProduct,
this.mnAddInstalledCheckWindowsUpdate});
this.menuChecks.Text = "Chec&ks";
//
// mnAddInstalledCheckRegistry
Expand Down Expand Up @@ -474,6 +478,12 @@ private void InitializeComponent()
this.mnAddInstalledCheckProduct.Text = "Installed Check ProductCode";
this.mnAddInstalledCheckProduct.Click += new System.EventHandler(this.mnAddInstalledCheckProduct_Click);
//
// mnAddInstalledCheckWindowsUpdate
//
this.mnAddInstalledCheckWindowsUpdate.Index = 5;
this.mnAddInstalledCheckWindowsUpdate.Text = "Installed Check Windows Update";
this.mnAddInstalledCheckWindowsUpdate.Click += new System.EventHandler(this.mnInstalledCheckWindowsUpdate_Click);
//
// menuDownload
//
this.menuDownload.Index = 3;
Expand Down Expand Up @@ -558,6 +568,12 @@ private void InitializeComponent()
this.mnAddHyperlinkControl.Text = "&Hyperlink";
this.mnAddHyperlinkControl.Click += new System.EventHandler(this.mnAddHyperlinkControl_Click);
//
// mnAddImageControl
//
this.mnAddImageControl.Index = 5;
this.mnAddImageControl.Text = "&Image";
this.mnAddImageControl.Click += new System.EventHandler(this.mnAddImageControl_Click);
//
// menuSep4
//
this.menuSep4.Index = 6;
Expand Down Expand Up @@ -773,15 +789,15 @@ private void InitializeComponent()
this.configurationTree.SelectedImageIndex = 0;
this.configurationTree.Size = new System.Drawing.Size(176, 278);
this.configurationTree.TabIndex = 1;
this.configurationTree.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView_DragDrop);
this.configurationTree.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView_ItemDrag);
this.configurationTree.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView_BeforeSelect);
this.configurationTree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
this.configurationTree.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown);
this.configurationTree.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView_DragDrop);
this.configurationTree.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeView_DragEnter);
this.configurationTree.KeyUp += new System.Windows.Forms.KeyEventHandler(this.treeView_KeyUp);
this.configurationTree.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView_BeforeSelect);
this.configurationTree.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView_KeyDown);
this.configurationTree.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView_ItemDrag);
this.configurationTree.DragOver += new System.Windows.Forms.DragEventHandler(this.treeView_DragOver);
this.configurationTree.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView_KeyDown);
this.configurationTree.KeyUp += new System.Windows.Forms.KeyEventHandler(this.treeView_KeyUp);
this.configurationTree.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown);
//
// statusStrip
//
Expand Down Expand Up @@ -810,12 +826,6 @@ private void InitializeComponent()
this.txtComment.TabIndex = 0;
this.txtComment.Visible = false;
//
// mnAddImageControl
//
this.mnAddImageControl.Index = 5;
this.mnAddImageControl.Text = "&Image";
this.mnAddImageControl.Click += new System.EventHandler(this.mnAddImageControl_Click);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
Expand All @@ -825,11 +835,12 @@ private void InitializeComponent()
this.Menu = this.mainMenu;
this.Name = "MainForm";
this.Text = "Installer Editor";
this.Load += new System.EventHandler(this.MainForm_Load);
this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
this.Load += new System.EventHandler(this.MainForm_Load);
this.mainSplitContainer.Panel1.ResumeLayout(false);
this.mainSplitContainer.Panel2.ResumeLayout(false);
this.mainSplitContainer.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).EndInit();
this.mainSplitContainer.ResumeLayout(false);
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
Expand Down Expand Up @@ -1206,6 +1217,7 @@ private void RefreshNodeContextMenu()
mnAddInstalledCheckDirectory.Enabled = (item.Children.CanAdd(typeof(InstalledCheckDirectory)));
mnAddInstalledCheckRegistry.Enabled = (item.Children.CanAdd(typeof(InstalledCheckRegistry)));
mnAddInstalledCheckProduct.Enabled = (item.Children.CanAdd(typeof(InstalledCheckProduct)));
mnAddInstalledCheckWindowsUpdate.Enabled = (item.Children.CanAdd(typeof(InstalledCheckWindowsUpdate)));
mnAddInstalledCheckOperator.Enabled = (item.Children.CanAdd(typeof(InstalledCheckOperator)));
mnAddComponentWizard2.Enabled = (item is SetupConfiguration);
mnMoveUp.Enabled = (configurationTree.SelectedNode.PrevNode != null);
Expand Down Expand Up @@ -1236,6 +1248,7 @@ private void RefreshNodeContextMenu()
mnAddInstalledCheckDirectory.Enabled = false;
mnAddInstalledCheckRegistry.Enabled = false;
mnAddInstalledCheckProduct.Enabled = false;
mnAddInstalledCheckWindowsUpdate.Enabled = false;
mnAddInstalledCheckOperator.Enabled = false;
mnAddComponentWizard2.Enabled = false;
mnMove.Enabled = false;
Expand Down Expand Up @@ -1312,6 +1325,11 @@ private void mnAddInstalledCheckDirectory_Click(object sender, EventArgs e)
AddTreeNode_Click<InstalledCheckDirectory>();
}

private void mnInstalledCheckWindowsUpdate_Click(object sender, EventArgs e)
{
AddTreeNode_Click<InstalledCheckWindowsUpdate>();
}

private void mnAddLabelControl_Click(object sender, EventArgs e)
{
AddTreeNode_Click<ControlLabel>();
Expand Down Expand Up @@ -2059,5 +2077,6 @@ public void OpenMRUFile(string fileName)
}

#endregion

}
}
18 changes: 9 additions & 9 deletions InstallerEditor/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,26 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="contextMenuTreeView.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="contextMenuTreeView.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>134, 17</value>
</metadata>
<metadata name="imageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="imageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>307, 17</value>
</metadata>
<data name="imageList.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAu
JgAAAk1TRnQBSQFMAgEBGwEAAaQBAAGkAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
JgAAAk1TRnQBSQFMAgEBGwEAAbQBAAG0AQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAAXADAAEBAQABCAYAARwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down Expand Up @@ -296,10 +296,10 @@
AcABAQH4AQABwAEDAQABAwHgAQMB/AEAAcABAwEAAQcB8AEHAf4BBAHAAQMBAAEPAfwBPwL/AcABBws=
</value>
</data>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>410, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAkAEBAQAAAAAAAoAQAAlgAAABAQAAABAAgAaAUAAL4BAAAgIBAAAAAAAOgCAAAmBwAAICAAAAEA
Expand Down
11 changes: 11 additions & 0 deletions InstallerEditor/TreeNodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static XmlTreeNodeImpl CreateNode(XmlClass item)
else if (item is InstalledCheckRegistry) node = new TreeNodenstalledCheckRegistry(item as InstalledCheckRegistry);
else if (item is InstalledCheckOperator) node = new TreeNodeInstalledCheckOperator(item as InstalledCheckOperator);
else if (item is InstalledCheckProduct) node = new TreeNodeInstalledCheckProduct(item as InstalledCheckProduct);
else if (item is InstalledCheckWindowsUpdate) node = new TreeNodeInstalledCheckWindowsUpdate(item as InstalledCheckWindowsUpdate);
else if (item is ControlCheckBox) node = new TreeNodeControlCheckbox(item as ControlCheckBox);
else if (item is ControlLabel) node = new TreeNodeControlLabel(item as ControlLabel);
else if (item is ControlEdit) node = new TreeNodeControlEdit(item as ControlEdit);
Expand Down Expand Up @@ -528,6 +529,16 @@ public TreeNodeInstalledCheckProduct(InstalledCheckProduct value)
}
}

public class TreeNodeInstalledCheckWindowsUpdate : TreeNodeInstalledCheck<InstalledCheckWindowsUpdate>
{
public TreeNodeInstalledCheckWindowsUpdate(InstalledCheckWindowsUpdate value)
: base(value)
{
ImageIndex = 11;
SelectedImageIndex = 11;
}
}

public class TreeNodenstalledCheckDirectory : TreeNodeInstalledCheck<InstalledCheckDirectory>
{
public TreeNodenstalledCheckDirectory(InstalledCheckDirectory value)
Expand Down
2 changes: 2 additions & 0 deletions InstallerLib/InstalledCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public static InstalledCheck CreateFromXml(XmlElement element)
l_check = new InstalledCheckRegistry();
else if (element.Attributes["type"].InnerText == "check_product")
l_check = new InstalledCheckProduct();
else if (element.Attributes["type"].InnerText == "check_wus")
l_check = new InstalledCheckWindowsUpdate();
else
throw new Exception(string.Format(
"Invalid installcheck type: {0}", element.Attributes["type"].InnerText));
Expand Down
56 changes: 56 additions & 0 deletions InstallerLib/InstalledCheckWindowsUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.ComponentModel;

namespace InstallerLib
{
/// <summary>
/// InstalledCheck of type "wus".
/// </summary>
public class InstalledCheckWindowsUpdate : InstalledCheck
{
private string m_knowledgeBaseId;
private bool m_defaultValue;

public InstalledCheckWindowsUpdate() : base("check_wus")
{
this.KnowledgeBaseId = "KB123456789";
this.DefaultValue = false;
}

/// <summary>
/// Gets or sets the knowledge base ID of the QFE hotfix.
/// </summary>
[Description("QFE Knowledge base ID.")]
[Required]
public string KnowledgeBaseId
{
get { return this.m_knowledgeBaseId; }
set { this.m_knowledgeBaseId = value; }
}

/// <summary>
/// Gets or sets a value indicating the default value for the check.
/// </summary>
[Description("Default value for the check.")]
public bool DefaultValue
{
get { return this.m_defaultValue; }
set { this.m_defaultValue = value; }
}

/// <inheritdoc />
protected override void OnXmlWriteTag(XmlWriterEventArgs e)
{
e.XmlWriter.WriteAttributeString("kb_id", this.m_knowledgeBaseId);
e.XmlWriter.WriteAttributeString("default_value", this.m_defaultValue.ToString());
base.OnXmlWriteTag(e);
}

/// <inheritdoc />
protected override void OnXmlReadTag(XmlElementEventArgs e)
{
ReadAttributeValue(e, "kb_id", ref this.m_knowledgeBaseId);
ReadAttributeValue(e, "default_value", ref this.m_defaultValue);
base.OnXmlReadTag(e);
}
}
}
1 change: 1 addition & 0 deletions InstallerLib/InstallerLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<Compile Include="InstalledCheckOperator.cs" />
<Compile Include="InstalledCheckProduct.cs" />
<Compile Include="InstalledCheckRegistry.cs" />
<Compile Include="InstalledCheckWindowsUpdate.cs" />
<Compile Include="InstallerLinker.cs" />
<Compile Include="InstallerLinkerArguments.cs" />
<Compile Include="Lcid.cs" />
Expand Down
2 changes: 1 addition & 1 deletion dni.debug.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalOptions>/nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib Msi.lib %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib Msi.lib Wbemuuid.lib %(AdditionalOptions)</AdditionalOptions>
<AdditionalLibraryDirectories>$(SolutionDir)\ThirdParty\Msi\lib;$(SolutionDir)\ThirdParty\Microsoft\Visual Studio 14.0\VC\PlatformSDK\Lib;$(SolutionDir)ThirdParty\Microsoft\Visual Studio 14.0\VC\lib;$(SolutionDir)ThirdParty\Microsoft\Visual Studio 14.0\VC\atlmfc\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
Expand Down
2 changes: 1 addition & 1 deletion dni.debug.vsprops
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib Msi.lib"
AdditionalOptions="/nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib Msi.lib Wbemuuid.lib"
AdditionalLibraryDirectories="&quot;$(SolutionDir)\ThirdParty\Msi\lib&quot;;$(SolutionDir)\ThirdParty\Microsoft\Visual Studio 14.0\VC\PlatformSDK\Lib;$(SolutionDir)ThirdParty\Microsoft\Visual Studio 14.0\VC\lib;$(SolutionDir)ThirdParty\Microsoft\Visual Studio 14.0\VC\atlmfc\lib"
GenerateDebugInformation="true"
/>
Expand Down
Loading

0 comments on commit 99f9f34

Please sign in to comment.