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 <windows.h>
7 #include <shellapi.h>
8 
9 namespace openmsx {
10 
11 ArgumentGenerator::~ArgumentGenerator()
12 {
13  for (int i = 0; i < argc; ++i) {
14  free(argv[i]);
15  }
16 }
17 
18 char** ArgumentGenerator::GetArguments(int& argc_)
19 {
20  if (argv.empty()) {
21  LPWSTR* pszArglist = CommandLineToArgvW(GetCommandLineW(), &argc);
22  if (!pszArglist) {
23  throw MSXException("Failed to obtain command line arguments");
24  }
25 
26  argv.resize(argc);
27  for (int i = 0; i < argc; ++i) {
28  argv[i] = strdup(utf8::utf16to8(pszArglist[i]).c_str());
29  }
30  LocalFree(pszArglist);
31  }
32 
33  argc_ = argc;
34  return argv.data();
35 }
36 
37 } // namespace openmsx
38 
39 #endif
win32-arggen.hh
MSXException.hh
utf8_checked.hh
utf8::utf16to8
octet_iterator utf16to8(u16bit_iterator start, u16bit_iterator end, octet_iterator result)
Definition: utf8_checked.hh:204
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5