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