Special consideration is required for argv[0]. On Unix, 
this argument passes the part of the command line that is used to locate 
the executable. Prolog uses this to find the file holding the running 
executable. The Windows version uses this to find a module 
of the running executable. If the specified module cannot be found, it 
tries the module libpl.dll, containing the Prolog runtime 
kernel. In all these cases, the resulting file is used for two purposes:
- See whether a Prolog saved state is appended to the file. If this is 
the case, this state will be loaded instead of the default boot.prcfile from the SWI-Prolog home directory. See also qsave_program/[1,2] and section 11.5.
- Find the Prolog home directory. This process is described in detail in section 11.6.
PL_initialise() returns 1 if all initialisation succeeded and 0 otherwise.bugVarious fatal errors may cause PL_initialise() to call PL_halt(1), preventing it from returning at all.
In most cases, argc and argv will be passed 
from the main program. It is allowed to create your own argument vector, 
provided
argv[0] is constructed according to the rules above. For 
example:
int
main(int argc, char **argv)
{ char *av[10];
  int ac = 0;
  av[ac++] = argv[0];
  av[ac++] = "-x";
  av[ac++] = "mystate";
  av[ac]   = NULL;
  if ( !PL_initialise(ac, av) )
    PL_halt(1);
  ...
}
Please note that the passed argument vector may be referred from Prolog at any time and should therefore be valid as long as the Prolog engine is used.
A good setup in Windows is to add SWI-Prolog's bin 
directory to your PATH and either pass a module holding a 
saved state, or
"libpl.dll" as argv[0]. If the Prolog state is 
attached to a DLL (see the -dll option of swipl-ld), 
pass the name of this DLL.