Ian Branch 128 Posted October 26, 2022 Hi Team, In a simple Win32 App, when might ExtractFilePath(Application.ExeName) not be the same as TDirectory.GetCurrentDirectory if called in the Main Form?? Regards & TIA, Ian Share this post Link to post
Lajos Juhász 295 Posted October 26, 2022 The program was started with a different current folder option, or the WIN API SetCurrentDirectory was called somewhere from the application. Share this post Link to post
Ian Branch 128 Posted October 26, 2022 Tks Lajos, Neither apply in my situation. Ian Share this post Link to post
haentschman 92 Posted October 26, 2022 Hi... https://docwiki.embarcadero.com/Libraries/Seattle/en/System.IOUtils.TDirectory.GetCurrentDirectory Quote Returns the current working directory. Use GetCurrentDirectory to get the current directory Current working directory: 99% <> ExtractFilePath(Application.ExeName) Quote or the WIN API SetCurrentDirectory was called somewhere Example: Current working directory can be "C:\Windows\System32" or else a special folder... Share this post Link to post
Fr0sT.Brutal 900 Posted October 26, 2022 1 hour ago, Ian Branch said: Neither apply in my situation. Start it via shortcut and prepare for surprise Share this post Link to post
David Heffernan 2354 Posted October 26, 2022 2 hours ago, Ian Branch said: Tks Lajos, Neither apply in my situation. Ian This can only be true if you are the only person ever to run your program. These two things, the directory containing the executable and the working directory are completely different and unrelated things. Generally you don't want to use the working directory in a GUI program. It's really only useful in a console app where you can think of the working directory as one of the inputs to the process. What problem are you actually trying to solve? Share this post Link to post
SwiftExpat 65 Posted October 26, 2022 My experience it is one of these: command line is different dir than exe Short cut start in: Share this post Link to post
Ian Branch 128 Posted October 26, 2022 Hi Guys, Thank you for your inputs. I wasn't trying to solve any particular problem, just curious. Ian Share this post Link to post