diff --git a/build/win32/platform_specific_code/juce_win32_PlatformUtils.cpp b/build/win32/platform_specific_code/juce_win32_PlatformUtils.cpp index e6242f9602..33eeabf01d 100644 --- a/build/win32/platform_specific_code/juce_win32_PlatformUtils.cpp +++ b/build/win32/platform_specific_code/juce_win32_PlatformUtils.cpp @@ -185,6 +185,12 @@ bool juce_IsRunningInWine() throw() return false; } +//============================================================================== +const String JUCE_CALLTYPE PlatformUtilities::getCurrentCommandLineParams() throw() +{ + return String (::GetCommandLineW()); +} + //============================================================================== static void* currentModuleHandle = 0; diff --git a/juce.h b/juce.h index be87f31561..06b79ff6bc 100644 --- a/juce.h +++ b/juce.h @@ -186,23 +186,24 @@ END_JUCE_NAMESPACE #ifdef _CONSOLE #define START_JUCE_APPLICATION(AppClass) \ - int main (int argc, char* argv[]) \ + int main (int, char* argv[]) \ { \ - return JUCE_NAMESPACE::JUCEApplication::main (argc, argv, new AppClass()); \ + JUCE_NAMESPACE::String commandLineString (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ + return JUCE_NAMESPACE::JUCEApplication::main (commandLineString, new AppClass()); \ } #elif ! defined (_AFXDLL) #ifdef _WINDOWS_ #define START_JUCE_APPLICATION(AppClass) \ - int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR commandLine, int) \ + int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ { \ - JUCE_NAMESPACE::String commandLineString (commandLine); \ + JUCE_NAMESPACE::String commandLineString (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ return JUCE_NAMESPACE::JUCEApplication::main (commandLineString, new AppClass()); \ } #else #define START_JUCE_APPLICATION(AppClass) \ - int __stdcall WinMain (int, int, const char* commandLine, int) \ + int __stdcall WinMain (int, int, const char*, int) \ { \ - JUCE_NAMESPACE::String commandLineString (commandLine); \ + JUCE_NAMESPACE::String commandLineString (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ return JUCE_NAMESPACE::JUCEApplication::main (commandLineString, new AppClass()); \ } #endif diff --git a/src/juce_appframework/application/juce_Application.cpp b/src/juce_appframework/application/juce_Application.cpp index 10110caacd..4c19436bcb 100644 --- a/src/juce_appframework/application/juce_Application.cpp +++ b/src/juce_appframework/application/juce_Application.cpp @@ -280,11 +280,11 @@ int JUCEApplication::shutdownAppAndClearUp (const bool useMaximumForce) int JUCEApplication::main (int argc, char* argv[], JUCEApplication* const newApp) { - juce_setCurrentExecutableFileName (argv[0]); + juce_setCurrentExecutableFileName (String::fromUTF8 ((const uint8*) argv[0])); String cmd; for (int i = 1; i < argc; ++i) - cmd << argv[i] << T(' '); + cmd << String::fromUTF8 ((const uint8*) argv[i]) << T(' '); return JUCEApplication::main (cmd, newApp); } diff --git a/src/juce_core/misc/juce_PlatformUtilities.h b/src/juce_core/misc/juce_PlatformUtilities.h index cbffa8e897..2320aa8d84 100644 --- a/src/juce_core/misc/juce_PlatformUtilities.h +++ b/src/juce_core/misc/juce_PlatformUtilities.h @@ -139,6 +139,11 @@ public: */ static void JUCE_CALLTYPE setCurrentModuleInstanceHandle (void* newHandle) throw(); + /** WIN32 ONLY - Gets the command-line params as a string. + + This is needed to avoid unicode problems with the argc type params. + */ + static const String JUCE_CALLTYPE getCurrentCommandLineParams() throw(); #endif /** Clears the floating point unit's flags.