3 #define CMDLINE_SIZE 4096
5 #define WISH_EXE L"C:/Software/TclTk/bin/wish84.exe"
6 #define XCLIBDIR L"C:/Software/xcircuit/xcircuit-3.4"
9 wchar_t *parse_args(LPWSTR
*wargv
, int argc
)
12 static wchar_t buffer
[1024];
15 for (i
=1; i
<argc
; i
++) {
16 if (_waccess(wargv
[i
], 0) == 0) {
18 while ((c
=wcschr(wargv
[i
], L
'\\')) != NULL
)
20 wcscat(buffer
, L
"\\\"");
21 wcscat(buffer
, wargv
[i
]);
22 wcscat(buffer
, L
"\\\" ");
24 /*wcscat(buffer, wargv[i]);
25 wcscat(buffer, L" ");*/
32 static wchar_t wish_exe
[1024] = {0};
33 static wchar_t lib_path
[1024] = {0};
38 DWORD bufLen
= 1024 * sizeof(wchar_t);
42 if (RegOpenKeyW(HKEY_LOCAL_MACHINE
, L
"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\xcircuit-dev-win32.exe", &hKey
))
54 bufLen
= 1024 * sizeof(wchar_t);
65 for (i
=0; lib_path
[i
] != 0; i
++)
66 if (lib_path
[i
] == L
'\\')
68 _snwprintf(buf
, 1100, L
"XCIRCUIT_LIB_DIR=%ws", lib_path
);
74 int APIENTRY
WinMain(HINSTANCE hInst
, HINSTANCE hPrevInst
, LPSTR lpCmdLine
, int cmdShow
)
77 wchar_t *cmdLine
, *arg_str
;
80 PROCESS_INFORMATION pi
;
82 wargv
= CommandLineToArgvW(GetCommandLineW(), &argc
);
84 cmdLine
= (wchar_t*)malloc(sizeof(wchar_t)*CMDLINE_SIZE
);
85 arg_str
= parse_args(wargv
, argc
);
88 _snwprintf(cmdLine
, CMDLINE_SIZE
,
89 L
"\"%ws\" \"%ws/tkcon.tcl\" -eval \"source \"\"%ws/console.tcl\"\"\" -slave \"package require Tk; set argv [list %ws]; set argc [llength argv]; source \"\"%ws/xcircuit.tcl\"\"\"",
90 wish_exe
, lib_path
, lib_path
, arg_str
, lib_path
);
91 /*MessageBoxW(NULL, cmdLine, L"Info", MB_OK);*/
92 ZeroMemory(&si
, sizeof(STARTUPINFOW
));
93 si
.cb
= sizeof(STARTUPINFOW
);
94 if (!CreateProcessW(NULL
,
109 MessageBox(NULL
, "Unable to start xcircuit process", "Error", MB_OK
);