Delphi gets the current path of the executable file

Source: Internet
Author: User

There are Extractfiledir and extractfilepath two similar functions in the Delphi sysutils unit, and two functions have the following differences:
Extractfilepath returns the last character of the value is the backslash "/".
ShowMessage (Extractfiledir (application.exename)); The return value is C:/temp
ShowMessage (Extractfilepath (application.exename)); The return value is c:/temp/
Same point: If the execution file is in the root directory (such as: c:/sample). EXE), the return value of both is the same, and the last character is "/".
===============================================================================
Edit1. TEXT:=PARAMSTR (0)//own full path C:/555/qq.exe, available for console
Edit1.text:=expandfilename (paramstr (0)); Get the full path to this program C:/qq/2.exe
Edit2.text:=extractfiledir (paramstr (0)); Get the path to this program C:/QQ
Edit3.text:=application. EXEName; Get the full path to this program C:/qq/2.exe, same as 1th
Edit4.text:=extractfilename (Application.exename); Get filename 2.exe

Expandfilename () returns the full path to the file (including the drive, path)
Extractfileext () extracts the extension
Extractfilename () from the file name
to extract the file name without the path Extractfilepath () Extracts the pathname from the file name
Extractfiledir () extracts the directory name from the file name
Extractfiledrive () extracts the drive name from the file name
Changefileext () Change file extension
Expanduncfilename () returns the file full path containing the network drive
Extractrelativepath () extracts relative path information from file name
Extractshortpathname () Converts the file name to DOS 8 3 format
Matchesmask () checks to see if the file matches the specified file name format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.