aboutsummaryrefslogtreecommitdiffstats
path: root/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'script.c')
-rw-r--r--script.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/script.c b/script.c
index e186eb9..260e8b2 100644
--- a/script.c
+++ b/script.c
@@ -60,6 +60,11 @@
# endif /* def __sgi__ */
#endif /* def __SVR4 */
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h> /* GetModuleFileName */
+#endif
+
/* Concatentate str2 onto str1 at position n and return concatenated
string if file exists; 0 otherwise. */
@@ -167,7 +172,22 @@ char *find_impl_file(exec_path, generic_name, initname, sep)
char *sepptr = strrchr(exec_path, sep[0]);
char *extptr = exec_path + strlen(exec_path);
char *path = 0;
- /* fprintf(stderr, "dld_find_e %s\n", exec_path); fflush(stderr); */
+
+#ifdef _WIN32
+ char exec_buf[MAX_PATH];
+ HMODULE mod = GetModuleHandle(0); /* Returns module handle to current executable. */
+
+ if (mod) {
+ GetModuleFileName(mod, exec_buf, sizeof(exec_buf));
+ exec_path = exec_buf;
+ }
+#endif
+
+ /*fprintf(stderr, "dld_find_e %s\n", exec_path); fflush(stderr);*/
+
+ sepptr = strrchr(exec_path, sep[0]);
+ extptr = exec_path + strlen(exec_path);
+
if (sepptr) {
long sepind = sepptr - exec_path + 1L;