3 #include <QApplication>
5 // -------------------------------------------------------------------------
6 int main( int argc, char* argv[] )
8 // TODO ::setenv( "LC_NUMERIC", "POSIX", 1 );
9 QApplication a( argc, argv );
16 // -------------------------------------------------------------------------
26 class Win32CommandLineConverter
29 std::unique_ptr< char*[ ] > argv_;
30 std::vector< std::unique_ptr< char[ ] > > storage_;
33 Win32CommandLineConverter( )
35 LPWSTR cmd_line = GetCommandLineW( );
37 LPWSTR* w_argv = CommandLineToArgvW( cmd_line, &argc );
38 argv_ = std::unique_ptr< char*[ ] >( new char*[ argc ] );
39 storage_.reserve( argc );
40 for( int i = 0; i < argc; ++i )
42 storage_.push_back( ConvertWArg( w_argv[ i ] ) );
43 argv_[ i ] = storage_.back( ).get( );
50 return( static_cast< int >(storage_.size( ) ) );
54 return( argv_.get( ) );
56 static std::unique_ptr< char[ ] > ConvertWArg( LPWSTR w_arg )
58 int size = WideCharToMultiByte(
59 CP_UTF8, 0, w_arg, -1, nullptr, 0, nullptr, nullptr
61 std::unique_ptr< char[ ] > ret( new char[ size ] );
63 CP_UTF8, 0, w_arg, -1, ret.get( ), size, nullptr, nullptr
71 HINSTANCE hPrevInstance,
76 Win32CommandLineConverter cmd_line;
77 return( main( cmd_line.argc( ), cmd_line.argv( ) ) );