blob: 72dd921c5e6087daf19b9bca8cd2d84816f997de (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 );
}
|