Uses httpapp, masks; Procedure tform1.button1click (Sender: tobject); var SS, S: string; begin // extract the string SS: = application. exename; showmessage (SS); // C: \ Documents ents and Settings \ WY \ My Documents ents \ rad studio \ projects \ project1.exe // path S: = extractfilepath (SS ); showmessage (s); // C: \ Documents ents and Settings \ WY \ My Documents ents \ rad studio \ projects \ // folder S: = extractfiledir (SS ); showmessage (s); // C: \ Documents And Settings \ WY \ My Documents ents \ rad studio \ projects // Logical Disk S: = extractfiledrive (SS); showmessage (s); // C: // file name s: = extractfilename (SS); showmessage (s); // project1.exe // file extension S: = extractfileext (SS); showmessage (s );//. EXE // relative path S: = extractrelativepath ('C: \ Documents and Settings \ WY \ My Documents \ ', SS); showmessage (s ); // rad studio \ projects \ project1.exe // short file name s under DOS: = extract?pathname (SS ); Showmessage (s); // C: \ w.e ~ 1 \ WY \ mydocu ~ 1 \ radstu ~ 1 \ projects \ project1.exe // convert to the Unix path format. Uses httpapp S: = dospathtounixpath (SS); showmessage (s); // C: /Documents and Settings/WY/My Documents documents/rad studio/projects/project1.exe // convert the Unix path format to window format, which is the inverse operation s of dospathtounixpath: = expanduncfilename (dospathtounixpath (SS); showmessage (s); // C: \ Documents and Settings \ WY \ My Documents \ rad studio \ projects \ project1.exe // remove the end path separator S: = excludetrailingpathdelimiter (extractfilepath (SS); showmessage (s ); // C: \ Documents ents and Settings \ WY \ My Documents ents \ rad studio \ projects // remove the path separator at the end, just call: excludetrailingpathdelimiter s: = excludetrailingbackslash (extractfilepath (SS); showmessage (s); // C: \ Documents and Settings \ WY \ My Documents ents \ rad studio \ projects // change the extension, the file is not modified, but the string S: = changefileext (SS ,'. bak '); showmessage (s); // C: \ Documents ents and Settings \ WY \ My Documents ents \ rad studio \ projects \ project1.bak // change file path: s: = changefilepath (SS, 'c: \ Temp '); showmessage (s); // C: \ temp \ project1.exe // determines whether the first character is a path separator: ispathdelimiter (SS, 3); // return true // determine whether the suffix is exe; uses masks matchesmask (SS ,'*. EXE '); // returns trueend;
// Decompose processpath (uses filectrl required) var S, P, F: string; D: Char; begin S: = paramstr (0); showmessage (s); // C: \ Documents and Settings \ WY \ My Documents ents \ rad studio \ projects \ project1.exe processpath (S, D, P, f); showmessage (d); // C showmessage (P ); // \ Documents ents and Settings \ WY \ My Documents ents \ rad studio \ projects showmessage (f); // project1.exeend;
// Compress and display minimizename (uses filectrl required) var S: string; begin S: = paramstr (0); s: = minimizename (S, self. canvas, 100); showmessage (s); // C :\... \ project1.exeend;