| e8555c89 Andy McCall |
1 |
#ifdef _WIN32 |
| 2 |
|
| 3 |
#include "win32-arggen.hh" |
| 4 |
#include "MSXException.hh" |
| 5 |
#include "utf8_checked.hh" |
| 6 |
#include "xrange.hh" |
| 7 |
#include <windows.h> |
| 8 |
#include <shellapi.h> |
| 9 |
|
| 10 |
namespace openmsx { |
| 11 |
|
| 12 |
ArgumentGenerator::ArgumentGenerator() |
| 13 |
{ |
| 14 |
int argc = 0; |
| 15 |
LPWSTR* pszArgList = CommandLineToArgvW(GetCommandLineW(), &argc); |
| 16 |
if (!pszArgList) { |
| 17 |
throw MSXException("Failed to obtain command line arguments"); |
| 18 |
} |
| 19 |
|
| 20 |
args = dynarray<char*>(argc); |
| 21 |
for (auto i : xrange(argc)) { |
| 22 |
args[i] = strdup(utf8::utf16to8(pszArgList[i]).c_str()); |
| 23 |
} |
| 24 |
LocalFree(pszArgList); |
| 25 |
} |
| 26 |
|
| 27 |
ArgumentGenerator::~ArgumentGenerator() |
| 28 |
{ |
| 29 |
for (auto* arg : args) { |
| 30 |
free(arg); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
#endif |