GetModuleFileName mysteries

Ralf Juengling juenglin at
Mon Dec 22 14:52:38 CST 2003

I have some Windows code that uses GetModuleFileName in order 
to read some additional files at runtime that are expected at
certain place relative to the executable.

In Wine, GetModuleFileName doesn't work as intended, and I have
trouble to track down the problem. I had to use winemaker's "wrap"
option in order to work around initialization problems (C++ code).
So the application, "" is just a small wrapper
which loads "" via "LoadLibrary" and calls the
dll's "WinMain".

The startup script (a copy of wineapploader named "memview")
determines the application's name to be "memview.exe" and thus 
executes "wine memview.exe". Under these circumstances,
GetModulFileName yields "C:\WINDOWS\SYSTEM\memview.exe", which
is not correct. 
If I alter the winapploader script so that wine gets called
with "" instead, GetModuleFileName yields
which is the correct path (but "memview.exe" doesn't exist).

There is a second application which I built the very same way
(i.e. using a small wrapper "" which loads the 
actual code contained in the DLL ""). This 
application also uses GetModuleFileName; here it always yields
"C:\WINDOWS\SYSTEM\phaeaco.dll", no matter whether the 
application name given to wine by the wineapploader script is
"phaeaco.exe" or "".

This is a confusing picture. Could somebody point out what the
expected result of GetModuleFileName is for this scenario (the
full path to the dll, I guess) and how it comes about that it
yields a path "C:\WINDOWS\SYSTEM\..."?

I observed this with Wine-20031118, haven't tested more recent


Ralf Juengling <juenglin at>

More information about the wine-devel mailing list