Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Getting the file path of the application?

KosanKosan Member Posts: 4
Hello, I'm making a audio player in Borland C++ Builder 6.0, and one of the features I want to give it is for it to remember what was in the playlist when the program closed the last time (so the user doesn't always have to load up the same songs).

This all works fine when I save the playlist in the folder that I type in the code, but if I move the actual player to some other place, I want the playlist to be saved in that folder where the player currently is. Is there a way to find out where the player's exe file is currently so that I can save the playlist in the exact folder?


  • LundinLundin Member Posts: 3,711
    You need to use the Windows API functions GetCurrentDirectory() and SetCurrentDirectory(), found in Windows.h.
  • GalaadGalaad Member Posts: 2
    You can get the current directory of the application with the ExeName property of the current TApplication object as follow:

    AnsiString exeFile=Application->ExeName;
    AnsiString exePath=ExtractFilePath(exeFile);

    NB: "Application" is the global object of the current application.
  • KosanKosan Member Posts: 4
    Thank you so much, it works now
Sign In or Register to comment.