Switch to unified view

a/src/windows/rclstartw.cpp b/src/windows/rclstartw.cpp
...
...
17
#include "autoconfig.h"
17
#include "autoconfig.h"
18
18
19
#include <shellapi.h>
19
#include <shellapi.h>
20
#include <stdio.h>
20
#include <stdio.h>
21
#include <stdlib.h>
21
#include <stdlib.h>
22
#include "safewindows.h"
23
#include "pathut.h"
24
#include "transcode.h"
22
25
23
using namespace std;
26
using namespace std;
24
27
25
// This exists only because I could not find any way to get "cmd /c
28
// 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,
29
// start fn" to work when executed from the recoll GUI. Otoh,
...
...
39
int op_flags;
42
int op_flags;
40
#define OPT_m 0x1
43
#define OPT_m 0x1
41
44
42
int main(int argc, char *argv[])
45
int main(int argc, char *argv[])
43
{
46
{
47
    int wargc;
48
    wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);
49
50
    // Yes we could use wargv
44
    thisprog = argv[0];
51
    thisprog = argv[0];
45
    argc--; argv++;
52
    argc--; argv++;
46
    int imode = 0;
53
    int imode = 0;
47
    while (argc > 0 && **argv == '-') {
54
    while (argc > 0 && **argv == '-') {
48
    (*argv)++;
55
    (*argv)++;
...
...
60
    }
67
    }
61
68
62
    if (argc != 1) {
69
    if (argc != 1) {
63
        Usage();
70
        Usage();
64
    }
71
    }
72
65
    char *fn = strdup(argv[0]);
73
    wchar_t *wfn = wargv[1];
74
66
    // Do we need this ?
75
    // Do we need this ?
67
    //https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
76
    //https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
68
    //CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
77
    //CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
69
78
70
    int wmode = SW_SHOWNORMAL;
79
    int wmode = SW_SHOWNORMAL;
71
    switch (imode) {
80
    switch (imode) {
72
    case 1: wmode = SW_SHOWMAXIMIZED;break;
81
    case 1: wmode = SW_SHOWMAXIMIZED;break;
73
    default: wmode = SW_SHOWNORMAL;  break;
82
    default: wmode = SW_SHOWNORMAL;  break;
74
    }
83
    }
75
    
84
    
76
    int ret = (int)ShellExecute(NULL, "open", fn, NULL, NULL, wmode);
85
    int ret = (int)ShellExecuteW(NULL, L"open", wfn, NULL, NULL, wmode);
77
    if (ret) {
86
    if (ret) {
78
        fprintf(stderr, "ShellExecute returned %d\n", ret);
87
        fprintf(stderr, "ShellExecute returned %d\n", ret);
79
    }
88
    }
89
    LocalFree(wargv);
80
    return ret;
90
    return ret;
81
}
91
}