diff --git a/DepotDownloader/PlatformUtilities.cs b/DepotDownloader/PlatformUtilities.cs index 2386eae2..31d26e9e 100644 --- a/DepotDownloader/PlatformUtilities.cs +++ b/DepotDownloader/PlatformUtilities.cs @@ -145,5 +145,35 @@ namespace DepotDownloader : mode & ~ModeExecute))); } } + + #region WIN32_CONSOLE_STUFF + [DllImport("kernel32.dll", SetLastError = true)] + static extern uint GetConsoleProcessList(uint[] processList, uint processCount); + + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] + static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type); + + const uint MB_OK = 0x0; + const uint MB_ICONWARNING = 0x30; + + public static void VerifyConsoleLaunch() + { + // Reference: https://devblogs.microsoft.com/oldnewthing/20160125-00/?p=92922 + var processList = new uint[2]; + var processCount = GetConsoleProcessList(processList, (uint)processList.Length); + + if (processCount != 1) + { + return; + } + + _ = MessageBox( + IntPtr.Zero, + "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.", + "DepotDownloader", + MB_OK | MB_ICONWARNING + ); + } + #endregion } } diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index 058654cf..50db98b7 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -21,6 +21,12 @@ namespace DepotDownloader if (args.Length == 0) { PrintUsage(); + + if (OperatingSystem.IsWindows()) + { + PlatformUtilities.VerifyConsoleLaunch(); + } + return 1; }