openUrl全路径转换

This commit is contained in:
龙仨
2024-04-27 16:32:20 +08:00
parent 292b85bcbd
commit a56326dfaa
2 changed files with 7 additions and 5 deletions
+5 -4
View File
@@ -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)
{
+2 -1
View File
@@ -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
{