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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/* tclshellexe.c - Interface to Windows ShellExecute function.
Copyright (C) 1997 Cygnus Solutions.
Written by Tom Tromey <tromey@cygnus.com>;
Code mostly taken from S-N. */
#ifdef _WIN32
#include <string.h>
#include <windows.h>
#include <tcl.h>
#include <tk.h>
#include "guitcl.h"
static int
shell_execute_command (ClientData clientData, Tcl_Interp *interp,
int argc, char *argv[])
{
char *operation;
char *file;
char *param;
char *dir;
int ret;
if (argc < 3 || argc > 5)
{
Tcl_AppendResult(interp, "wrong # args: should be \"",
argv[0], " operation file ?parameters? ?directory?\"", NULL);
return TCL_ERROR;
}
operation = argv[1]; /* Mandatory */
if (!*operation)
operation = NULL;
file = argv[2]; /* Mandatory */
if (argc > 3)
{
param = argv[3];
if (!*param)
param = NULL;
}
else
param = NULL;
if (argc > 4)
{
dir = argv[4];
if (!*dir)
dir = NULL;
}
else
dir = NULL;
ret = (int)ShellExecute(NULL, operation, file, param, dir, SW_SHOWNORMAL);
if (ret <= 32)
{
Tcl_AppendResult(interp, strerror(ret), NULL);
return TCL_ERROR;
}
return TCL_OK;
}
int
ide_create_shell_execute_command (Tcl_Interp *interp)
{
if (Tcl_CreateCommand (interp, "ide_shell_execute", shell_execute_command,
NULL, NULL) == NULL)
return TCL_ERROR;
return TCL_OK;
}
#endif /* _WIN32 */
|