#include #include #include #include int WINAPI WinMain( HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // pointer to command line int nCmdShow // show state of window ) { char *args[4], *prog = NULL; char pathbuffer[_MAX_PATH]; char searchfile[] = "php.exe"; char envvar[] = "PATH"; char *path = getenv("PATH"); char newpath[2048]; char newfile[2048]; char default_php_file[] = " phpmole-ide.php "; sprintf(newfile,"%s %s", default_php_file,lpCmdLine); sprintf(newpath, "PATH=c:\\php4;d:\\php4;%s ", path); putenv(newpath); /* if (strlen(lpCmdLine) == 0) MessageBox(NULL, "Usage: php_win \n", "Error", MB_OK); */ if (!(prog = getenv("PHP_BIN"))) { _searchenv( searchfile, envvar, pathbuffer ); if (strlen(pathbuffer)) prog = pathbuffer; } args[0] = prog; args[1] = "-q"; args[2] = newfile; args[3] = NULL; if (prog) return _spawnvp(_P_DETACH, prog, args); else { MessageBox(NULL, "PHP.EXE was not found.", "Error", MB_OK); return -1; } }