openMSX
win32-arggen.cc
Go to the documentation of this file.
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
10namespace openmsx {
11
12ArgumentGenerator::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
27ArgumentGenerator::~ArgumentGenerator()
28{
29 for (auto* arg : args) {
30 free(arg);
31 }
32}
33
34} // namespace openmsx
35
36#endif
This file implemented 3 utility functions:
Definition Autofire.cc:11
octet_iterator utf16to8(u16bit_iterator start, u16bit_iterator end, octet_iterator result)
constexpr auto xrange(T e)
Definition xrange.hh:132