#include <vcl.h>
#include <string.h>

#include "param_fix.h"

int argc;
static char ModuleFname[2048];
char *argv[11]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};


/** This function converts Windows GUI arguments to command line argument format. */
void PatchArgs(LPSTR CmdLine)
{
int len;
char *radek;

  argc=1;

  radek=CmdLine;
  len=strlen(CmdLine);
  while(len-->0)
  {
    if(isspace(*radek))
    {
		*radek=0;
		radek++;
		continue;
    }
    if(argc>sizeof(argv)/sizeof(char*)) break;
    argv[argc++]=radek;
    radek++;
    while((*radek>' ')&(len>=0))
    {
      radek++;
      len--;
    }
  }

	// Get name of executable to parameter 0.
  len = GetModuleFileName(NULL, ModuleFname, sizeof(ModuleFname));
  if(len>0) argv[0]=ModuleFname;
}