The snippet was for Leffmann - and it still only allows building up the absolute path from the current directory, not the one the exe is in.
For example, if you put the exe in c:, then cd sys:, then run c:exename, getting a lock on the dirname "" (empty string) is a lock on sys: because that was your current directory (for that shell process, presumably).
The best option to me seems to be to use relative paths for all loaded files and make sure those work in some way external to the program, like executing a script or editing an icon (if that's possible).
|