Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/UniGetUI.Avalonia/Infrastructure/AvaloniaAppHost.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Runtime.InteropServices;
using Avalonia;
using UniGetUI.Core.Data;
using UniGetUI.Core.Logging;
using UniGetUI.Core.Tools;
using UniGetUI.Interface;

namespace UniGetUI.Avalonia.Infrastructure;
Expand Down Expand Up @@ -43,6 +45,27 @@ public static void Run(string[] args)

CoreData.WasDaemon = CoreData.IsDaemon = args.Contains(AvaloniaCliHandler.DAEMON);

string textart = $"""
__ __ _ ______ __ __ ______
/ / / /___ (_) ____/__ / /_/ / / / _/
/ / / / __ \/ / / __/ _ \/ __/ / / // /
/ /_/ / / / / / /_/ / __/ /_/ /_/ // /
\____/_/ /_/_/\____/\___/\__/\____/___/
Welcome to UniGetUI Version {CoreData.VersionName}
""";

Logger.ImportantInfo(textart);
Logger.ImportantInfo(" ");
Logger.ImportantInfo($"Build {CoreData.BuildNumber}");
Logger.ImportantInfo("UI Framework: Avalonia");
Logger.ImportantInfo($"Data directory {CoreData.UniGetUIDataDirectory}");
Logger.ImportantInfo($"OS: {RuntimeInformation.OSDescription}");
Logger.ImportantInfo($"Process arch: {RuntimeInformation.ProcessArchitecture} (OS: {RuntimeInformation.OSArchitecture})");
Logger.ImportantInfo($"Runtime: {RuntimeInformation.FrameworkDescription}");
Logger.ImportantInfo($"Elevated: {CoreTools.IsAdministrator()}");
Logger.ImportantInfo($"Packaged (MSIX): {CoreTools.IsPackagedApp()}");
Logger.ImportantInfo($"Args: {(args.Length > 0 ? string.Join(" ", args) : "(none)")}");

if (!TryRegisterSingleInstance(args))
{
return;
Expand Down
29 changes: 29 additions & 0 deletions src/UniGetUI.Core.Tools/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Net;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Text;
Expand Down Expand Up @@ -291,6 +292,34 @@ public static bool IsAdministrator()
}
}

/// <summary>
/// Checks whether the current process is running inside an MSIX package (Store / sideloaded).
/// </summary>
/// <returns>True when packaged, false when running unpackaged or on a non-Windows platform.</returns>
public static bool IsPackagedApp()
{
if (!OperatingSystem.IsWindows())
{
return false;
}

try
{
int len = 0;
int rc = GetCurrentPackageFullName(ref len, IntPtr.Zero);
return rc != APPMODEL_ERROR_NO_PACKAGE;
}
catch
{
return false;
}
}

private const int APPMODEL_ERROR_NO_PACKAGE = 15700;

[DllImport("kernel32.dll", SetLastError = false)]
private static extern int GetCurrentPackageFullName(ref int packageFullNameLength, IntPtr packageFullName);

public static Task<long> GetFileSizeAsLongAsync(Uri? url) =>
Task.Run(() => GetFileSizeAsLong(url));

Expand Down
10 changes: 10 additions & 0 deletions src/UniGetUI/EntryPoint.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Runtime.InteropServices;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.Windows.AppLifecycle;
using UniGetUI.Core.Data;
using UniGetUI.Core.Logging;
using UniGetUI.Core.Tools;
using UniGetUI.Interface;
using UniGetUI.Shared;

Expand Down Expand Up @@ -89,8 +91,16 @@ Welcome to UniGetUI Version {CoreData.VersionName}
Logger.ImportantInfo(textart);
Logger.ImportantInfo(" ");
Logger.ImportantInfo($"Build {CoreData.BuildNumber}");
Logger.ImportantInfo("UI Framework: WinUI 3");
Logger.ImportantInfo($"Data directory {CoreData.UniGetUIDataDirectory}");
Logger.ImportantInfo($"Encoding Code Page set to {CoreData.CODE_PAGE}");
Logger.ImportantInfo($"OS: {RuntimeInformation.OSDescription}");
Logger.ImportantInfo($"Process arch: {RuntimeInformation.ProcessArchitecture} (OS: {RuntimeInformation.OSArchitecture})");
Logger.ImportantInfo($"Runtime: {RuntimeInformation.FrameworkDescription}");
Logger.ImportantInfo($"Elevated: {CoreTools.IsAdministrator()}");
Logger.ImportantInfo($"Packaged (MSIX): {CoreTools.IsPackagedApp()}");
string[] cmdArgs = Environment.GetCommandLineArgs();
Logger.ImportantInfo($"Args: {(cmdArgs.Length > 1 ? string.Join(" ", cmdArgs.Skip(1)) : "(none)")}");

// WinRT single-instance fancy stuff
WinRT.ComWrappersSupport.InitializeComWrappers();
Expand Down
Loading