2 #include <QApplication>
4 // -------------------------------------------------------------------------
5 int main( int argc, char* argv[] )
7 QApplication a( argc, argv );
14 // -------------------------------------------------------------------------
24 class Win32CommandLineConverter
27 std::unique_ptr< char*[ ] > argv_;
28 std::vector< std::unique_ptr< char[ ] > > storage_;
31 Win32CommandLineConverter( )
33 LPWSTR cmd_line = GetCommandLineW( );
35 LPWSTR* w_argv = CommandLineToArgvW( cmd_line, &argc );
36 argv_ = std::unique_ptr< char*[ ] >( new char*[ argc ] );
37 storage_.reserve( argc );
38 for( int i = 0; i < argc; ++i )
40 storage_.push_back( ConvertWArg( w_argv[ i ] ) );
41 argv_[ i ] = storage_.back( ).get( );
48 return( static_cast< int >(storage_.size( ) ) );
52 return( argv_.get( ) );
54 static std::unique_ptr< char[ ] > ConvertWArg( LPWSTR w_arg )
56 int size = WideCharToMultiByte(
57 CP_UTF8, 0, w_arg, -1, nullptr, 0, nullptr, nullptr
59 std::unique_ptr< char[ ] > ret( new char[ size ] );
61 CP_UTF8, 0, w_arg, -1, ret.get( ), size, nullptr, nullptr
69 HINSTANCE hPrevInstance,
74 Win32CommandLineConverter cmd_line;
75 return( main( cmd_line.argc( ), cmd_line.argv( ) ) );