----- Original Message -----|
From: Wesley Smith
Date: 1/29/2008 8:35 PM
Unless support/ is in the PATH, launching MyApp.exe will fail.On Jan 29, 2008 7:29 PM, Fabio Mascarenhas <firstname.lastname@example.org> wrote:Just put it in the same path as your .exe and you will be ok.True. It's kind of lame though to have everything flat in the dir like that. Ideally I'd have MyApp.exe support/ lua51.dll ... (other dlls) Is this possible through some kind of build/linking option or should I just get over it?
You can cheat the system, though.
Add lua51.dll to the Delay Load DLLs list. As soon as your application hits main()/WinMain(), call GetModuleFileName() to retrieve the full filename of MyApp.exe (don't rely on argv). Strip the MyApp.exe from there to get the path to MyApp.exe and append support/lua51.dll to it. Call LoadLibrary(pathExcludingMyAppExe + "support/lua51.dll"). Then everything will work as normal.
If delay loading a DLL isn't an option (I can't remember what OS it was introduced in), then you'll have to either launch your app with a batch file:
or with a stub executable that sets the PATH and then launches the real MyApp.exe.