Skip to content

Commit

Permalink
Verify OneNote registration at installation
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencohn authored and weissm committed Jan 22, 2024
1 parent 8a40725 commit ca8d224
Show file tree
Hide file tree
Showing 6 changed files with 850 additions and 266 deletions.
57 changes: 57 additions & 0 deletions OneMoreSetupActions/Actions/CheckBitnessAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//************************************************************************************************
// Copyright © 2021 Steven M Cohn. All rights reserved.
//************************************************************************************************

namespace OneMoreSetupActions
{
using System;
using System.Windows.Forms;


/// <summary>
/// Confirms that the installer bitness matches the OS bitness
/// </summary>
internal class CheckBitnessAction : CustomAction
{
private readonly bool x64;


public CheckBitnessAction(Logger logger, Stepper stepper, bool x64)
: base(logger, stepper)
{
this.x64 = x64;
}


public override int Install()
{
logger.WriteLine();
logger.WriteLine("CheckBitnessAction.Install ---");

var oarc = Environment.Is64BitOperatingSystem ? "x64" : "x86";
var iarc = Environment.Is64BitProcess ? "x64" : "x86";
var rarc = x64 ? "x64" : "x86";
logger.WriteLine($"Installer architecture ({iarc}), OS architecture ({oarc}), requesting ({rarc})");

if (Environment.Is64BitOperatingSystem != Environment.Is64BitProcess ||
Environment.Is64BitOperatingSystem != x64)
{
var msg = $"Installer architecture ({iarc}) does not match OS ({oarc}) or request ({rarc})";
logger.WriteLine(msg);

MessageBox.Show(msg,
"Incompatible Installer", MessageBoxButtons.OK, MessageBoxIcon.Error);

return FAILURE;
}

return SUCCESS;
}


public override int Uninstall()
{
return SUCCESS;
}
}
}
Loading

0 comments on commit ca8d224

Please sign in to comment.