RE: win32 port



Title: RE: win32 port

> -----Original Message-----
> From: watchthinker [mailto:watchthinker netease com]
> Sent: Friday, June 29, 2001 6:16 PM
> To: gtk-list gnome org
> Subject: win32 port
>
>
> Dear All:
>
>       I am new to gtk.
>
>       I want to use gtk to write win32 programs. But when the complied
> program run, there is a console window appears.
>
>       What to do to close the console windows?
>
>       Thanks!
>
>
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>

Well, suppose you have your code already written in Linux and you would like to run it under Win32 without no mayor changes.  Suppose you already have your main function defined so you could type something like this:

#ifdef WIN32

static int
breakargs(char *program, char *line, char **argv)
{
  int argc = 1;

  argv[0] = program;

  while(*line)
  { while(*line && isspace(*line))
      line++;

    if ( *line == '"' )                 /* Windows-95 quoted arguments */
    { char *start = line+1;
      char *end = start;

      while( *end && *end != '"' )
        end++;
      if ( *end == '"' )
      { *end = '\0';
        argv[argc++] = start;
        line = end+1;
        continue;
      }
    }

    if ( *line )
    { argv[argc++] = line;
      while(*line && !isspace(*line))
        line++;
      if ( *line )
        *line++ = '\0';
    }
  }
  argv[argc] = NULL; /* add trailing NULL pointer to argv */

  return argc;
}

int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nShowCmd)
{
  char *argv[100];                                        
  int  argc;                                              
  TCHAR program[MAXPATHLEN];                              

  GetModuleFileName(hInstance, program, sizeof(program)); 
  argc = breakargs((char *)program, lpszCmdLine, argv);   
  main(argc, argv);
  return 0;
}

#endif /*WIN32*/

Esteban Quijano
Artinsoft corp.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]