*/
apr_status_t rv;
char *def_server_root;
- char fnbuf[MAX_PATH];
+ char *binpath;
char optbuf[3];
const char *optarg;
int fixed_args;
* The requested service's (-n) registry ConfigArgs
* The WinNT SCM's StartService() args
*/
- if (!GetModuleFileName(NULL, fnbuf, sizeof(fnbuf))) {
- rv = apr_get_os_error();
+ if ((rv = ap_os_proc_filepath(&binpath, process->pconf))
+ != APR_SUCCESS) {
ap_log_error(APLOG_MARK,APLOG_CRIT, rv, NULL,
- "Failed to get the path of Apache.exe");
+ "Failed to get the full path of %s", process->argv[0]);
exit(APEXIT_INIT);
}
/* WARNING: There is an implict assumption here that the
* executable resides in ServerRoot or ServerRoot\bin
*/
- def_server_root = (char *) apr_filename_of_pathname(fnbuf);
- if (def_server_root > fnbuf) {
+ def_server_root = (char *) apr_filename_of_pathname(binpath);
+ if (def_server_root > binpath) {
*(def_server_root - 1) = '\0';
- def_server_root = (char *) apr_filename_of_pathname(fnbuf);
+ def_server_root = (char *) apr_filename_of_pathname(binpath);
if (!strcasecmp(def_server_root, "bin"))
*(def_server_root - 1) = '\0';
}
- apr_filepath_merge(&def_server_root, NULL, fnbuf,
+ apr_filepath_merge(&def_server_root, NULL, binpath,
APR_FILEPATH_TRUENAME, process->pool);
/* Use process->pool so that the rewritten argv