+// ---------------------------------------------------------------------------
+// Convert Windows to argc, argv style
+// ---------------------------------------------------------------------------
+
+wxChar **ConvertToStandardCommandArgs(const wxChar *p, int& argc)
+{
+ // break the command line in words
+ wxArrayString args;
+ if ( p )
+ {
+ args = wxCmdLineParser::ConvertStringToArgs(p);
+ }
+
+ // +1 here for the program name
+ argc = args.GetCount() + 1;
+
+ // and +1 here for the terminating NULL
+ wxChar **argv = new wxChar *[argc + 1];
+
+ // as we use wxStrdup below we must allocate the first argument using
+ // malloc(), not new[], as well
+ argv[0] = (wxChar *)malloc(MAX_PATH * sizeof(wxChar));
+ ::GetModuleFileName(wxhInstance, argv[0], MAX_PATH);
+
+ // copy all the other arguments to wxApp::argv[]
+ for ( int i = 1; i < argc; i++ )
+ {
+ argv[i] = wxStrdup(args[i - 1]);
+ }
+
+ // argv[] must be NULL-terminated
+ argv[argc] = NULL;
+
+ return argv;
+}
+
+#endif // wxUSE_GUI
+