]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - Plugson/src/main_windows.c
keep up with 1.0.67 (#1464)
[Ventoy.git] / Plugson / src / main_windows.c
index 910dfe53746262d91d49d07e8a3bfe1ca7ce8096..e6a0bf47a0f361751e9dca618c4114d8e9976c94 100644 (file)
@@ -10,6 +10,8 @@
 #include <ventoy_disk.h>\r
 #include <ventoy_http.h>\r
 \r
 #include <ventoy_disk.h>\r
 #include <ventoy_http.h>\r
 \r
+char g_ventoy_dir[MAX_PATH];
+\r
 static BOOL g_running = FALSE;\r
 static HWND g_refresh_button;\r
 static HWND g_start_button;\r
 static BOOL g_running = FALSE;\r
 static HWND g_refresh_button;\r
 static HWND g_start_button;\r
@@ -34,6 +36,7 @@ typedef enum MSGID
        MSGID_BTN_STOP_TIP, \r
        MSGID_BTN_EXIT_TIP,\r
        MSGID_RUNNING_TIP,\r
        MSGID_BTN_STOP_TIP, \r
        MSGID_BTN_EXIT_TIP,\r
        MSGID_RUNNING_TIP,\r
+       MSGID_NO_TARXZ_TIP,\r
 \r
     MSGID_BUTT\r
 }MSGID;\r
 \r
     MSGID_BUTT\r
 }MSGID;\r
@@ -56,6 +59,7 @@ const WCHAR *g_msg_cn[MSGID_BUTT] =
        L"Í£Ö¹ÔËÐкóä¯ÀÀÆ÷Ò³Ãæ½«»á¹Ø±Õ£¬ÊÇ·ñ¼ÌÐø£¿",\r
        L"µ±Ç°·þÎñÕýÔÚÔËÐУ¬ÊÇ·ñÍ˳ö£¿",\r
        L"ÇëÏȹرÕÕýÔÚÔËÐеĠVentoyPlugson ³ÌÐò£¡",\r
        L"Í£Ö¹ÔËÐкóä¯ÀÀÆ÷Ò³Ãæ½«»á¹Ø±Õ£¬ÊÇ·ñ¼ÌÐø£¿",\r
        L"µ±Ç°·þÎñÕýÔÚÔËÐУ¬ÊÇ·ñÍ˳ö£¿",\r
        L"ÇëÏȹرÕÕýÔÚÔËÐеĠVentoyPlugson ³ÌÐò£¡",\r
+       L"ventoy\\plugson.tar.xz Îļþ²»´æÔÚ£¬ÇëÔÚÕýÈ·µÄĿ¼ÏÂÔËÐУ¡",\r
 };\r
 const WCHAR *g_msg_en[MSGID_BUTT] =\r
 {\r
 };\r
 const WCHAR *g_msg_en[MSGID_BUTT] =\r
 {\r
@@ -74,6 +78,7 @@ const WCHAR *g_msg_en[MSGID_BUTT] =
        L"The browser page will close after stop, continue?",\r
        L"Service is running, continue?",\r
        L"Please close another running VentoyPlugson instance!",\r
        L"The browser page will close after stop, continue?",\r
        L"Service is running, continue?",\r
        L"Please close another running VentoyPlugson instance!",\r
+       L"ventoy\\plugson.tar.xz does not exist, please run under the correct directory!",\r
 };\r
 \r
 const WCHAR **g_msg_lang = NULL;\r
 };\r
 \r
 const WCHAR **g_msg_lang = NULL;\r
@@ -463,6 +468,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 {\r
     int rc;\r
        HANDLE hMutex;\r
 {\r
     int rc;\r
        HANDLE hMutex;\r
+       WCHAR CurDir[MAX_PATH];\r
 \r
     UNREFERENCED_PARAMETER(hPrevInstance);\r
 \r
 \r
     UNREFERENCED_PARAMETER(hPrevInstance);\r
 \r
@@ -484,10 +490,18 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
                return 1;\r
        }\r
 \r
                return 1;\r
        }\r
 \r
-       GetCurrentDirectoryA(MAX_PATH, g_cur_dir);\r
+       GetCurrentDirectoryW(MAX_PATH, CurDir);\r
+       WideCharToMultiByte(CP_UTF8, 0, CurDir, -1, g_cur_dir, MAX_PATH, NULL, 0);\r
+\r
+       sprintf_s(g_ventoy_dir, sizeof(g_ventoy_dir), "%s", g_cur_dir);\r
        sprintf_s(g_log_file, sizeof(g_log_file), "%s\\%s", g_cur_dir, LOG_FILE);\r
        ventoy_log_init();\r
 \r
        sprintf_s(g_log_file, sizeof(g_log_file), "%s\\%s", g_cur_dir, LOG_FILE);\r
        ventoy_log_init();\r
 \r
+    if (!ventoy_is_file_exist("%s\\ventoy\\%s", g_ventoy_dir, PLUGSON_TXZ))\r
+    {        \r
+               MessageBoxW(NULL, g_msg_lang[MSGID_NO_TARXZ_TIP], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);\r
+        return 1;\r
+    }\r
 \r
        ParseCmdLine(lpCmdLine, g_sysinfo.ip, g_sysinfo.port);\r
        if (g_sysinfo.ip[0] == 0)\r
 \r
        ParseCmdLine(lpCmdLine, g_sysinfo.ip, g_sysinfo.port);\r
        if (g_sysinfo.ip[0] == 0)\r