I apologise if this is a trivial question, but I have searched as much as I can and cannot find any solution.
I have a Delphi/FMX application that creates a DLL for Win32 and a DYLIB for macOS (High Sierra), 32 bits.
In a unit, I was simply using GetModuleName(hInstance)
to get the name of the module that used the unit, and that works fine in Win32 and Win64. For example, if the main program is using the unit it will return the main program name. If however, a DLL used by the main program uses the unit, it will return the DLL name. I'm using this to create separate log files for the main program and any DLLs it calls and using the name retuned in the log file name.
The code that works (which is in a unit used by a DYLIB (OSX)/DLL (Win32) created with FMX) in Windows is:
sModuleName := TPath.GetFileNameWithoutExtension(GetModuleName(hInstance));
GetModulename
is in the System.SysUtils unit and AFAIK there is no conditional define for Windows/OSX etc. My assumption, obviously wrong, is that it should work when built for OSX. It doesn't, it hangs on that line with no error, just an '(Not Responding)' in FORCE QUIT window. I have tried this on both a macOS VM and on a hard macOS system with the same result.
Is there something (else) I need to do to get GetModuleName working with OSX?
and/or
Is there something (similar) that will retrieve the module name if I build for OSX?