Return the root directory of Delphi executable -
i have delphi application executing , when call getcurrentdir
following returns:
c:\dev\w32\2015\bcslbdemo\win32\debug
when call extractfiledir(getcurrentdir())
receive following:
c:\dev\w32\2015\bcslbdemo\win32
what desire c:\dev\w32\2015\bcslbdemo
function retroot: string; var i: integer; buf: string; begin result := ''; buf := extractfiledir(getcurrentdir()); := length(buf); repeat dec(i); until (buf[i] = '\') or (i < 3); if buf[i] = '\' begin delete(buf, i, length(buf)); result := buf; end; end;
i wrote function desired result. know if there better approach accomplish retrieving root directory of delphi executable.
there's way:
expandfilename(getcurrentdir + '\..\..\'); // current folder expandfilename(extractfiledir(application.exename) + '\..\..\'); // exe folder
c:\dev\w32\2015\bcslbdemo
will take 2 levels can see.
of course answer "how 2 levels up" question. question exe root kind of non-sense. might need configure project settings not make win32\debug
folders or move data files there ;-)
Comments
Post a Comment