|
a/src/windows/rclstartw.cpp |
|
b/src/windows/rclstartw.cpp |
|
... |
|
... |
25 |
// This exists only because I could not find any way to get "cmd /c
|
25 |
// This exists only because I could not find any way to get "cmd /c
|
26 |
// start fn" to work when executed from the recoll GUI. Otoh,
|
26 |
// start fn" to work when executed from the recoll GUI. Otoh,
|
27 |
// cygstart, which uses ShellExecute() did work... So this is just a
|
27 |
// cygstart, which uses ShellExecute() did work... So this is just a
|
28 |
// simpler cygstart
|
28 |
// simpler cygstart
|
29 |
static char *thisprog;
|
29 |
static char *thisprog;
|
30 |
static char usage [] ="rclstartw <fn>\n"
|
30 |
static char usage [] ="rclstartw [-m] <fn>\n"
|
31 |
" Will use ShellExecute to open the arg with the default app\n";
|
31 |
" Will use ShellExecute to open the arg with the default app\n"
|
|
|
32 |
" -m 1 start maximized\n";
|
32 |
|
33 |
|
33 |
static void Usage(FILE *fp = stderr)
|
34 |
static void Usage(FILE *fp = stderr)
|
34 |
{
|
35 |
{
|
35 |
fprintf(fp, "%s: usage:\n%s", thisprog, usage);
|
36 |
fprintf(fp, "%s: usage:\n%s", thisprog, usage);
|
36 |
exit(1);
|
37 |
exit(1);
|
37 |
}
|
38 |
}
|
|
|
39 |
int op_flags;
|
|
|
40 |
#define OPT_m 0x1
|
38 |
|
41 |
|
39 |
int main(int argc, char *argv[])
|
42 |
int main(int argc, char *argv[])
|
40 |
{
|
43 |
{
|
41 |
thisprog = argv[0];
|
44 |
thisprog = argv[0];
|
42 |
argc--; argv++;
|
45 |
argc--; argv++;
|
|
|
46 |
int imode = 0;
|
|
|
47 |
while (argc > 0 && **argv == '-') {
|
|
|
48 |
(*argv)++;
|
|
|
49 |
if (!(**argv))
|
|
|
50 |
Usage();
|
|
|
51 |
while (**argv)
|
|
|
52 |
switch (*(*argv)++) {
|
|
|
53 |
case 'm': op_flags |= OPT_m; if (argc < 2) Usage();
|
|
|
54 |
if ((sscanf(*(++argv), "%d", &imode)) != 1)
|
|
|
55 |
Usage();
|
|
|
56 |
argc--; goto b1;
|
|
|
57 |
default: Usage(); break;
|
|
|
58 |
}
|
|
|
59 |
b1: argc--; argv++;
|
|
|
60 |
}
|
43 |
|
61 |
|
44 |
if (argc != 1) {
|
62 |
if (argc != 1) {
|
45 |
Usage();
|
63 |
Usage();
|
46 |
}
|
64 |
}
|
47 |
char *fn = strdup(argv[0]);
|
65 |
char *fn = strdup(argv[0]);
|
48 |
|
|
|
49 |
// Do we need this ?
|
66 |
// Do we need this ?
|
50 |
//https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
|
67 |
//https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
|
51 |
//CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
68 |
//CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
|
|
69 |
|
|
|
70 |
int wmode = SW_SHOWNORMAL;
|
|
|
71 |
switch (imode) {
|
|
|
72 |
case 1: wmode = SW_SHOWMAXIMIZED;break;
|
|
|
73 |
default: wmode = SW_SHOWNORMAL; break;
|
|
|
74 |
}
|
52 |
|
75 |
|
53 |
int ret = (int)ShellExecute(NULL, "open", fn, NULL, NULL, SW_SHOWNORMAL);
|
76 |
int ret = (int)ShellExecute(NULL, "open", fn, NULL, NULL, wmode);
|
54 |
if (ret) {
|
77 |
if (ret) {
|
55 |
fprintf(stderr, "ShellExecute returned %d\n", ret);
|
78 |
fprintf(stderr, "ShellExecute returned %d\n", ret);
|
56 |
}
|
79 |
}
|
57 |
return ret;
|
80 |
return ret;
|
58 |
}
|
81 |
}
|