Some fixes
This commit is contained in:
parent
50d56aa638
commit
723ae1ce7f
@ -70,14 +70,14 @@ namespace UpTool_build_tool
|
|||||||
{
|
{
|
||||||
installBat += "\r\n";
|
installBat += "\r\n";
|
||||||
installBat +=
|
installBat +=
|
||||||
$@"powershell ""$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk');$s.TargetPath='%cd%\{programName}.exe';$s.Save()""";
|
$@"powershell ""$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk');$s.TargetPath='%cd%\{mainBin}.exe';$s.Save()""";
|
||||||
removeBat += "\r\n";
|
removeBat += "\r\n";
|
||||||
removeBat += $@"del ""%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk""";
|
removeBat += $@"del ""%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk""";
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(mainBin))
|
if (!string.IsNullOrWhiteSpace(mainBin))
|
||||||
{
|
{
|
||||||
removeBat += "\r\n";
|
removeBat += "\r\n";
|
||||||
removeBat += $@"taskkill /f /im ""{programName}.exe""";
|
removeBat += $@"taskkill /f /im ""{Path.GetFileName(mainBin)}""";
|
||||||
}
|
}
|
||||||
installBat += "\r\ntimeout /t 1";
|
installBat += "\r\ntimeout /t 1";
|
||||||
removeBat += "\r\ntimeout /t 1";
|
removeBat += "\r\ntimeout /t 1";
|
||||||
|
12
UpTool2/MainForm.Designer.cs
generated
12
UpTool2/MainForm.Designer.cs
generated
@ -1,6 +1,6 @@
|
|||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
partial class MainForm
|
sealed partial class MainForm
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@ -143,8 +143,7 @@
|
|||||||
// infoPanel_Title
|
// infoPanel_Title
|
||||||
//
|
//
|
||||||
this.infoPanel_Title.AutoSize = true;
|
this.infoPanel_Title.AutoSize = true;
|
||||||
this.infoPanel_Title.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F,
|
this.infoPanel_Title.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F);
|
||||||
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (0)));
|
|
||||||
this.infoPanel_Title.Location = new System.Drawing.Point(2, 1);
|
this.infoPanel_Title.Location = new System.Drawing.Point(2, 1);
|
||||||
this.infoPanel_Title.Name = "infoPanel_Title";
|
this.infoPanel_Title.Name = "infoPanel_Title";
|
||||||
this.infoPanel_Title.Size = new System.Drawing.Size(0, 31);
|
this.infoPanel_Title.Size = new System.Drawing.Size(0, 31);
|
||||||
@ -190,7 +189,7 @@
|
|||||||
this.controls_upload.Anchor =
|
this.controls_upload.Anchor =
|
||||||
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||||
System.Windows.Forms.AnchorStyles.Right)));
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.controls_upload.Location = new System.Drawing.Point(283, 6);
|
this.controls_upload.Location = new System.Drawing.Point(284, 6);
|
||||||
this.controls_upload.Name = "controls_upload";
|
this.controls_upload.Name = "controls_upload";
|
||||||
this.controls_upload.Size = new System.Drawing.Size(27, 27);
|
this.controls_upload.Size = new System.Drawing.Size(27, 27);
|
||||||
this.controls_upload.TabIndex = 4;
|
this.controls_upload.TabIndex = 4;
|
||||||
@ -208,7 +207,7 @@
|
|||||||
this.filterBox.FormattingEnabled = true;
|
this.filterBox.FormattingEnabled = true;
|
||||||
this.filterBox.Location = new System.Drawing.Point(68, 7);
|
this.filterBox.Location = new System.Drawing.Point(68, 7);
|
||||||
this.filterBox.Name = "filterBox";
|
this.filterBox.Name = "filterBox";
|
||||||
this.filterBox.Size = new System.Drawing.Size(208, 23);
|
this.filterBox.Size = new System.Drawing.Size(209, 23);
|
||||||
this.filterBox.TabIndex = 3;
|
this.filterBox.TabIndex = 3;
|
||||||
this.filterBox.SelectedIndexChanged += new System.EventHandler(this.UpdateSidebarV);
|
this.filterBox.SelectedIndexChanged += new System.EventHandler(this.UpdateSidebarV);
|
||||||
//
|
//
|
||||||
@ -220,7 +219,7 @@
|
|||||||
System.Windows.Forms.AnchorStyles.Right)));
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.searchBox.Location = new System.Drawing.Point(3, 38);
|
this.searchBox.Location = new System.Drawing.Point(3, 38);
|
||||||
this.searchBox.Name = "searchBox";
|
this.searchBox.Name = "searchBox";
|
||||||
this.searchBox.Size = new System.Drawing.Size(306, 23);
|
this.searchBox.Size = new System.Drawing.Size(307, 23);
|
||||||
this.searchBox.TabIndex = 2;
|
this.searchBox.TabIndex = 2;
|
||||||
this.searchBox.TextChanged += new System.EventHandler(this.UpdateSidebarV);
|
this.searchBox.TextChanged += new System.EventHandler(this.UpdateSidebarV);
|
||||||
//
|
//
|
||||||
@ -267,7 +266,6 @@
|
|||||||
this.ShowIcon = false;
|
this.ShowIcon = false;
|
||||||
this.Text = "UpTool 2";
|
this.Text = "UpTool 2";
|
||||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||||
this.HelpRequested += new System.Windows.Forms.HelpEventHandler(this.MainForm_HelpRequested);
|
|
||||||
this.infoPanel.ResumeLayout(false);
|
this.infoPanel.ResumeLayout(false);
|
||||||
this.infoPanel.PerformLayout();
|
this.infoPanel.PerformLayout();
|
||||||
this.splitContainer.Panel1.ResumeLayout(false);
|
this.splitContainer.Panel1.ResumeLayout(false);
|
||||||
|
@ -4,26 +4,26 @@ using System.Drawing;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using UpTool2.DataStructures;
|
using UpTool2.DataStructures;
|
||||||
using UpTool2.Properties;
|
using UpTool2.Properties;
|
||||||
using UpTool2.Tool;
|
using UpTool2.Tool;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public sealed partial class MainForm : Form
|
||||||
{
|
{
|
||||||
|
HelpEventHandler help;
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
GlobalVariables.ReloadElements = ReloadElements;
|
GlobalVariables.ReloadElements = ReloadElements;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
help = MainForm_HelpRequested;
|
||||||
|
HelpRequested += help;
|
||||||
filterBox.DataSource = Enum.GetValues(typeof(Status));
|
filterBox.DataSource = Enum.GetValues(typeof(Status));
|
||||||
if (Program.Online)
|
if (Program.Online)
|
||||||
{
|
{
|
||||||
@ -154,7 +154,7 @@ namespace UpTool2
|
|||||||
action_update.Tag = app;
|
action_update.Tag = app;
|
||||||
action_update.Enabled = updatable;
|
action_update.Enabled = updatable;
|
||||||
action_run.Tag = app;
|
action_run.Tag = app;
|
||||||
action_run.Enabled = !app.Local && app.Runnable && Directory.Exists(app.appPath);
|
action_run.Enabled = (app.status & Status.Installed) == Status.Installed && !app.Local && app.Runnable && Directory.Exists(app.appPath);
|
||||||
};
|
};
|
||||||
if (updatable)
|
if (updatable)
|
||||||
availableUpdates++;
|
availableUpdates++;
|
||||||
@ -264,54 +264,48 @@ namespace UpTool2
|
|||||||
|
|
||||||
private static DateTime GetBuildDateTime(Assembly assembly)
|
private static DateTime GetBuildDateTime(Assembly assembly)
|
||||||
{
|
{
|
||||||
string path = assembly.GetName().CodeBase;
|
string location = assembly.Location;
|
||||||
if (File.Exists(path))
|
const int headerOffset = 60;
|
||||||
{
|
const int linkerTimestampOffset = 8;
|
||||||
byte[] buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
|
byte[] buffer = new byte[2048];
|
||||||
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
Stream? stream = null;
|
||||||
{
|
|
||||||
fileStream.Position = 0x3C;
|
|
||||||
fileStream.Read(buffer, 0, 4);
|
|
||||||
fileStream.Position = BitConverter.ToUInt32(buffer, 0); // COFF header offset
|
|
||||||
fileStream.Read(buffer, 0, 4); // "PE\0\0"
|
|
||||||
fileStream.Read(buffer, 0, buffer.Length);
|
|
||||||
}
|
|
||||||
GCHandle pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_IMAGE_FILE_HEADER coffHeader =
|
|
||||||
(_IMAGE_FILE_HEADER) Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(),
|
|
||||||
typeof(_IMAGE_FILE_HEADER));
|
|
||||||
|
|
||||||
return TimeZone.CurrentTimeZone.ToLocalTime(
|
try
|
||||||
new DateTime(1970, 1, 1) + new TimeSpan(coffHeader.TimeDateStamp * TimeSpan.TicksPerSecond));
|
{
|
||||||
}
|
stream = new FileStream(location, FileMode.Open, FileAccess.Read);
|
||||||
finally
|
stream.Read(buffer, 0, 2048);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (stream != null)
|
||||||
{
|
{
|
||||||
pinnedBuffer.Free();
|
stream.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new DateTime();
|
|
||||||
|
int i = BitConverter.ToInt32(buffer, headerOffset);
|
||||||
|
int secondsSince1970 = BitConverter.ToInt32(buffer, i + linkerTimestampOffset);
|
||||||
|
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0);
|
||||||
|
dt = dt.AddSeconds(secondsSince1970);
|
||||||
|
dt = TimeZoneInfo.ConvertTimeToUtc(dt);
|
||||||
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_HelpRequested(object sender, HelpEventArgs hlpevent)
|
private void MainForm_HelpRequested(object sender, HelpEventArgs hlpevent)
|
||||||
{
|
{
|
||||||
DateTime buildTime = GetBuildDateTime(Assembly.GetExecutingAssembly());
|
HelpRequested -= help;
|
||||||
_ = MessageBox.Show($@"UpTool2 by CC24
|
try
|
||||||
|
{
|
||||||
|
DateTime buildTime = GetBuildDateTime(Assembly.GetExecutingAssembly());
|
||||||
|
MessageBox.Show($@"UpTool2 by CC24
|
||||||
Version: {Assembly.GetExecutingAssembly().GetName().Version}
|
Version: {Assembly.GetExecutingAssembly().GetName().Version}
|
||||||
Build Date: {buildTime:dd.MM.yyyy}", "UpTool2");
|
Build Date: {buildTime:dd.MM.yyyy}", "UpTool2");
|
||||||
hlpevent.Handled = true;
|
}
|
||||||
}
|
finally
|
||||||
|
{
|
||||||
private struct _IMAGE_FILE_HEADER
|
HelpRequested += help;
|
||||||
{
|
hlpevent.Handled = true;
|
||||||
public ushort Machine;
|
}
|
||||||
public ushort NumberOfSections;
|
|
||||||
public uint TimeDateStamp;
|
|
||||||
public uint PointerToSymbolTable;
|
|
||||||
public uint NumberOfSymbols;
|
|
||||||
public ushort SizeOfOptionalHeader;
|
|
||||||
public ushort Characteristics;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -118,9 +118,9 @@
|
|||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.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>
|
</resheader>
|
||||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>184, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="searchPackageDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="searchPackageDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>107, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
</root>
|
</root>
|
Reference in New Issue
Block a user