+//// Convert Windows to argc, argv style
+
+void wxApp::ConvertToStandardCommandArgs(char* lpCmdLine)
+{
+ // Split command line into tokens, as in usual main(argc, argv)
+ char **command = new char*[50];
+
+ int count = 0;
+ char *buf = new char[strlen(lpCmdLine) + 1];
+
+ // Hangs around until end of app. in case
+ // user carries pointers to the tokens
+
+ /* Model independent strcpy */
+ int i;
+ for (i = 0; (buf[i] = lpCmdLine[i]) != 0; i++)
+ {
+ /* loop */;
+ }
+
+ // Get application name
+ char name[200];
+ ::GetModuleFileName(wxhInstance, name, 199);
+
+ // Is it only 16-bit Borland that already copies the program name
+ // to the first argv index?
+#if !defined(__GNUWIN32__)
+// #if ! (defined(__BORLANDC__) && !defined(__WIN32__))
+ command[count++] = copystring(name);
+// #endif
+#endif
+
+ strcpy(name, wxFileNameFromPath(name));
+ wxStripExtension(name);
+ wxTheApp->SetAppName(name);
+
+ /* Break up string */
+ // Treat strings enclosed in double-quotes as single arguments
+ char* str = buf;
+ while (*str)
+ {
+ while (*str && *str <= ' ') str++; // skip whitespace
+ if (*str == '"')
+ {
+ str++;
+ command[count++] = str;
+ while (*str && *str != '"') str++;
+ }
+ else if (*str)
+ {
+ command[count++] = str;
+ while (*str && *str > ' ') str++;
+ }
+ if (*str) *str++ = '\0';
+ }
+
+ wxTheApp->argv = new char*[argc+1];
+ wxTheApp->argv[count] = NULL; /* argv[] is NULL terminated list! */
+ wxTheApp->argc = count;
+
+ for (i = 0; i < count; i++)
+ {
+ wxTheApp->argv[i] = copystring(command[i]);
+ }
+ delete[] buf;
+}
+
+//// Cleans up any wxWindows internal structures left lying around
+