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 {