summaryrefslogtreecommitdiff
path: root/utils/itemtest/runexe.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/itemtest/runexe.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/itemtest/runexe.cpp')
-rw-r--r--utils/itemtest/runexe.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/utils/itemtest/runexe.cpp b/utils/itemtest/runexe.cpp
new file mode 100644
index 0000000..72dd921
--- /dev/null
+++ b/utils/itemtest/runexe.cpp
@@ -0,0 +1,52 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+
+#include <Windows.h> // GetModuleFileName, ShellExecute
+
+
+// Valve includes
+#include "strtools.h"
+#include "tier0/icommandline.h"
+#include "tier1/utlstring.h"
+
+
+// Last include
+#include "tier0/memdbgon.h"
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void RunExe()
+{
+ CUtlString sParameters;
+ ICommandLine *pCmdLine = CommandLine();
+
+ for ( int i = 1; i < pCmdLine->ParmCount(); ++i )
+ {
+ if ( i > 1 )
+ {
+ sParameters += " ";
+ }
+
+ const char *pszParm = pCmdLine->GetParm( i );
+ if ( strchr( pszParm, ' ' ) || strchr( pszParm, '\t' ) )
+ {
+ sParameters += "\"";
+ sParameters += pszParm;
+ sParameters += "\"";
+ }
+ else
+ {
+ sParameters += pszParm;
+ }
+ }
+
+ // Invoked with no command-line args: run in GUI mode.
+ char szExeName[ MAX_PATH ];
+ GetModuleFileName( NULL, szExeName, ARRAYSIZE( szExeName ) );
+ V_SetExtension( szExeName, ".exe", ARRAYSIZE( szExeName ) );
+ ShellExecute( NULL, _T( "open" ), szExeName, sParameters.String(), NULL, SW_SHOWNORMAL );
+}