From a56326dfaa8edc77b7fa3c19b7e67ddec6a34180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E4=BB=A8?= <9795869+e2long@user.noreply.gitee.com> Date: Sat, 27 Apr 2024 16:32:20 +0800 Subject: [PATCH] =?UTF-8?q?openUrl=E5=85=A8=E8=B7=AF=E5=BE=84=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dl/system/dl_windows.cpp | 9 +++++---- dl/system/dl_windows.h | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dl/system/dl_windows.cpp b/dl/system/dl_windows.cpp index a65f3974..d6f1e488 100644 --- a/dl/system/dl_windows.cpp +++ b/dl/system/dl_windows.cpp @@ -29,11 +29,12 @@ namespace dl::Win32 bool OpenUrl(std::string_view url, std::string_view cmd, - std::string_view work_path) + std::string_view work_path, + bool convert_absolute) { - std::string gbk_exe = dl::CodeCvt::Utf8ToMultiByte(dl::File::GetPathAbsolute(url)); - std::string gbk_cmd = dl::CodeCvt::Utf8ToMultiByte(dl::File::GetPathAbsolute(cmd)); - std::string gbk_path = dl::CodeCvt::Utf8ToMultiByte(dl::File::GetPathAbsolute(work_path)); + std::string gbk_exe = dl::CodeCvt::Utf8ToMultiByte(convert_absolute ? dl::File::GetPathAbsolute(url) : url); + std::string gbk_cmd = dl::CodeCvt::Utf8ToMultiByte(convert_absolute ? dl::File::GetPathAbsolute(cmd) : cmd); + std::string gbk_path = dl::CodeCvt::Utf8ToMultiByte(convert_absolute ? dl::File::GetPathAbsolute(work_path) : work_path); HINSTANCE h = ShellExecuteA(NULL, "open", gbk_exe.c_str(), gbk_cmd.c_str(), gbk_path.c_str(), SW_SHOW); if ((int)h <= 32) { diff --git a/dl/system/dl_windows.h b/dl/system/dl_windows.h index 242559b5..598fef9c 100644 --- a/dl/system/dl_windows.h +++ b/dl/system/dl_windows.h @@ -34,7 +34,8 @@ namespace dl::Win32 //! 打开网页、文件夹、文件、程序 bool OpenUrl(std::string_view url, std::string_view cmd = {}, - std::string_view work_path = {}); + std::string_view work_path = {}, + bool convert_absolute = true); // 常用路径检测文件是否存在 enum WindowsSearchType {