3
3
// PyStand.cpp -
4
4
//
5
5
// Created by skywind on 2022/02/03
6
- // Last Modified: 2022 /03/13 00:26
6
+ // Last Modified: 2023 /03/17 20:06
7
7
//
8
8
// =====================================================================
9
9
#ifdef _MSC_VER
10
10
#define _CRT_SECURE_NO_WARNINGS 1
11
11
#endif
12
12
13
- #include " PyStand.h"
14
13
#include < shlwapi.h>
15
14
#include < string>
16
15
#include < string.h>
17
16
#include < winbase.h>
18
17
#include < wincon.h>
19
18
19
+ #include " PyStand.h"
20
+
20
21
#ifdef _MSC_VER
21
22
#pragma comment(lib, "shlwapi.lib")
22
23
#endif
@@ -256,6 +257,15 @@ int PyStand::RunString(const char *script)
256
257
}
257
258
258
259
260
+
261
+ // ---------------------------------------------------------------------
262
+ // static init script
263
+ // ---------------------------------------------------------------------
264
+ #ifndef PYSTAND_STATIC_NAME
265
+ #define PYSTAND_STATIC_NAME " _pystand_static.int"
266
+ #endif
267
+
268
+
259
269
// ---------------------------------------------------------------------
260
270
// LoadScript()
261
271
// ---------------------------------------------------------------------
@@ -270,25 +280,34 @@ int PyStand::DetectScript()
270
280
std::wstring main = _pystand.substr (0 , size);
271
281
std::vector<const wchar_t *> exts;
272
282
std::vector<std::wstring> scripts;
273
- exts.push_back (L" .int" );
274
- exts.push_back (L" .py" );
275
- exts.push_back (L" .pyw" );
276
- _script = L" " ;
277
- for (int i = 0 ; i < (int )exts.size (); i++) {
278
- std::wstring test = main + exts[i];
279
- scripts.push_back (test);
280
- if (PathFileExistsW (test.c_str ())) {
281
- _script = test;
282
- break ;
283
- }
283
+ _script.clear ();
284
+ #if !(PYSTAND_DISABLE_STATIC)
285
+ std::wstring test;
286
+ test = _home + L" \\ " + Ansi2Unicode (PYSTAND_STATIC_NAME);
287
+ if (PathFileExistsW (test.c_str ())) {
288
+ _script = test;
284
289
}
285
- if (_script.size () == 0 ) {
286
- std::wstring msg = L" Can't find either of:\r\n " ;
287
- for (int j = 0 ; j < (int )scripts.size (); j++) {
288
- msg += scripts[j] + L" \r\n " ;
290
+ #endif
291
+ if (_script.empty ()) {
292
+ exts.push_back (L" .int" );
293
+ exts.push_back (L" .py" );
294
+ exts.push_back (L" .pyw" );
295
+ for (int i = 0 ; i < (int )exts.size (); i++) {
296
+ std::wstring test = main + exts[i];
297
+ scripts.push_back (test);
298
+ if (PathFileExistsW (test.c_str ())) {
299
+ _script = test;
300
+ break ;
301
+ }
302
+ }
303
+ if (_script.size () == 0 ) {
304
+ std::wstring msg = L" Can't find either of:\r\n " ;
305
+ for (int j = 0 ; j < (int )scripts.size (); j++) {
306
+ msg += scripts[j] + L" \r\n " ;
307
+ }
308
+ MessageBoxW (NULL , msg.c_str (), L" ERROR" , MB_OK);
309
+ return -1 ;
289
310
}
290
- MessageBoxW (NULL , msg.c_str (), L" ERROR" , MB_OK);
291
- return -1 ;
292
311
}
293
312
SetEnvironmentVariableW (L" PYSTAND_SCRIPT" , _script.c_str ());
294
313
return 0 ;
0 commit comments