Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=============================================================================
  4. #include <Windows.h> // GetModuleFileName, ShellExecute
  5. // Valve includes
  6. #include "strtools.h"
  7. #include "tier0/icommandline.h"
  8. #include "tier1/utlstring.h"
  9. // Last include
  10. #include "tier0/memdbgon.h"
  11. //-----------------------------------------------------------------------------
  12. //
  13. //-----------------------------------------------------------------------------
  14. void RunExe()
  15. {
  16. CUtlString sParameters;
  17. ICommandLine *pCmdLine = CommandLine();
  18. for ( int i = 1; i < pCmdLine->ParmCount(); ++i )
  19. {
  20. if ( i > 1 )
  21. {
  22. sParameters += " ";
  23. }
  24. const char *pszParm = pCmdLine->GetParm( i );
  25. if ( strchr( pszParm, ' ' ) || strchr( pszParm, '\t' ) )
  26. {
  27. sParameters += "\"";
  28. sParameters += pszParm;
  29. sParameters += "\"";
  30. }
  31. else
  32. {
  33. sParameters += pszParm;
  34. }
  35. }
  36. // Invoked with no command-line args: run in GUI mode.
  37. char szExeName[ MAX_PATH ];
  38. GetModuleFileName( NULL, szExeName, ARRAYSIZE( szExeName ) );
  39. V_SetExtension( szExeName, ".exe", ARRAYSIZE( szExeName ) );
  40. ShellExecute( NULL, _T( "open" ), szExeName, sParameters.String(), NULL, SW_SHOWNORMAL );
  41. }