X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fmain.cpp;h=dc8122dd3031bb02bcb43d10694f48b2760958e4;hp=9fdaba297c7ed8ef7c74b5e22e5d1c9eb289669c;hb=cc7ee0bc72ccd0ff51963132848aee3cddae8602;hpb=521cf1db00f8ce2d9f9494dca503d6c17d89ac2f diff --git a/source/core/main.cpp b/source/core/main.cpp index 9fdaba2..dc8122d 100644 --- a/source/core/main.cpp +++ b/source/core/main.cpp @@ -1,21 +1,40 @@ -/* $Id$ - -This file is part of libmspcore -Copyright © 2006 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ #ifdef WIN32 #include +#include +#include #endif - #include "application.h" #ifdef WIN32 -int APIENTRY WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/) +using namespace std; +using namespace Msp; + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/) { int argc = 0; - LPWSTR *argv=CommandLineToArgvW(GetCommandLineW(), &argc); - return Msp::Application::run(argc, (char **)argv); + LPWSTR *argv_w = CommandLineToArgvW(GetCommandLineW(), &argc); + + unsigned max_size = 0; + for(int i=0; i(argv_buf); + char *argv_ptr = argv_buf+(argc+1)*sizeof(char *); + for(int i=0; i(argv_w[i]), wcslen(argv_w[i])*2); + arg = StringCodec::transcode(arg); + copy(arg.begin(), arg.end(), argv_ptr); + argv_ptr += arg.size(); + *argv_ptr++ = 0; + } + + LocalFree(argv_w); + int exit_code = Msp::Application::run(argc, argv, hInstance); + delete[] argv_buf; + return exit_code; } #endif