mirror of
https://github.com/SteamRE/DepotDownloader.git
synced 2026-02-04 05:31:18 +01:00
Merge pull request #526 from SteamRE/alert
Display a message box when exe is not lauched from console
This commit is contained in:
@@ -19,6 +19,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="protobuf-net" Version="3.2.30" />
|
||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||
<PackageReference Include="SteamKit2" Version="3.0.0-Beta.2" />
|
||||
|
||||
2
DepotDownloader/NativeMethods.txt
Normal file
2
DepotDownloader/NativeMethods.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
GetConsoleProcessList
|
||||
MessageBox
|
||||
@@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace DepotDownloader
|
||||
{
|
||||
@@ -27,5 +28,25 @@ namespace DepotDownloader
|
||||
: mode & ~ModeExecute);
|
||||
}
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("windows5.0")]
|
||||
public static void VerifyConsoleLaunch()
|
||||
{
|
||||
// Reference: https://devblogs.microsoft.com/oldnewthing/20160125-00/?p=92922
|
||||
var processList = new uint[2];
|
||||
var processCount = Windows.Win32.PInvoke.GetConsoleProcessList(processList);
|
||||
|
||||
if (processCount != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ = Windows.Win32.PInvoke.MessageBox(
|
||||
Windows.Win32.Foundation.HWND.Null,
|
||||
"Depot Downloader is a console application; there is no GUI.\n\nIf you do not pass any command line parameters, it prints usage info and exits.\n\nYou must use this from a terminal/console.",
|
||||
"Depot Downloader",
|
||||
Windows.Win32.UI.WindowsAndMessaging.MESSAGEBOX_STYLE.MB_OK | Windows.Win32.UI.WindowsAndMessaging.MESSAGEBOX_STYLE.MB_ICONWARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,12 @@ namespace DepotDownloader
|
||||
if (args.Length == 0)
|
||||
{
|
||||
PrintUsage();
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
PlatformUtilities.VerifyConsoleLaunch();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user