Searching for php.ini only in %windir% is a problem when more than application is using PHP on the same Win32 machine. What you really want is behavior similar to PHP on Unix where php.ini is first looked for local to the PHP executable.
The following patch has PHP looking for the php.ini first in the same directory as PHP.exe and next in the Windows installation directory. Note that this change is backwards compatible. Index: main/php_ini.c =================================================================== RCS file: /repository/php4/main/php_ini.c,v retrieving revision 1.85 diff -u -b -r1.85 php_ini.c --- main/php_ini.c 19 Apr 2002 05:48:22 -0000 1.85 +++ main/php_ini.c 30 Apr 2002 14:51:59 -0000 @@ -226,19 +226,19 @@ php_ini_search_path = php_ini_path_override; free_ini_search_path = 0; } else { - char *default_location; - int free_default_location; - #ifdef PHP_WIN32 - default_location = (char *) emalloc(512); + char sSearchPath[1024]; + char *default_location = sSearchPath; - if (!GetWindowsDirectory(default_location, 255)) { - default_location[0]=0; - } - free_default_location=1; + /* Look in the same directory as the executable. */ + GetModuleFileName(0,sSearchPath,sizeof(sSearchPath)) || (sSearchPath[0] = 0); + { char* p = strrchr(sSearchPath,'\\'); if (p) *++p = 0; } + + /* Add the Windows base directory as well. */ + strncat(sSearchPath,";",sizeof(sSearchPath)); + { int n = strlen(sSearchPath); +GetWindowsDirectory(sSearchPath+n,sizeof(sSearchPath)-n); } #else - default_location = PHP_CONFIG_FILE_PATH; - free_default_location=0; + char *default_location = PHP_CONFIG_FILE_PATH; #endif php_ini_search_path = (char *) emalloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); free_ini_search_path = 1; @@ -255,9 +255,6 @@ sprintf(php_ini_search_path, ".%c%s", ZEND_PATHS_SEPARATOR, default_location); } } - if (free_default_location) { - efree(default_location); - } } PG(safe_mode) = 0; -- Preston L. Bannister http://members.cox.net/preston.bannister/ pbannister on Yahoo Messenger -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php