diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-05-09 16:37:27 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-11 20:38:01 +0200 |
| commit | bbe336ee97c86c424f8f94e0f947f8e3b20e7123 (patch) | |
| tree | 8e150d92ce7b7f151618aec8cc056d2df01dc5fc /src/lib/cross_windows.cc | |
| parent | 2695f450ca00654cef8709e4e3cfb4cf5de48fc7 (diff) | |
Use GetCommandLineW() to get a UTF16-encoded command line on Windows (#2248).
Diffstat (limited to 'src/lib/cross_windows.cc')
| -rw-r--r-- | src/lib/cross_windows.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc index 054961578..200b72485 100644 --- a/src/lib/cross_windows.cc +++ b/src/lib/cross_windows.cc @@ -44,10 +44,11 @@ extern "C" { #include <setupapi.h> #include <fileapi.h> #undef DATADIR -#include <shlwapi.h> -#include <shlobj.h> -#include <shellapi.h> #include <knownfolders.h> +#include <processenv.h> +#include <shellapi.h> +#include <shlobj.h> +#include <shlwapi.h> #include <fcntl.h> #include <fstream> #include <map> @@ -657,3 +658,17 @@ show_in_file_manager (boost::filesystem::path, boost::filesystem::path select) return (reinterpret_cast<int64_t>(r) <= 32); } + +ArgFixer::ArgFixer(int, char**) +{ + auto cmd_line = GetCommandLineW(); + auto wide_argv = CommandLineToArgvW(cmd_line, &_argc); + + _argv_strings.resize(_argc); + _argv = new char*[_argc]; + for (int i = 0; i < _argc; ++i) { + _argv_strings[i] = wchar_to_utf8(wide_argv[i]); + _argv[i] = const_cast<char*>(_argv_strings[i].c_str()); + } +} + |
