Delphi有这个函数的:
function ExtractFileDrive(const FileName: string): string;
Returns the drive portion of a file name.
Unit
SysUtils
Category
file name utilities
Delphi syntax:
function ExtractFileDrive(const FileName: string): string;
C++ syntax:
extern PACKAGE AnsiString __fastcall ExtractFileDrive(const AnsiString FileName);
Description
On Windows, ExtractFileDrive returns a string containing the drive portion of a fully qualified path name for the file passed in the FileName. For file names with drive letters, the result is in the form ?<drive>'? For file names with a UNC path the result is in the form ?//<servername>/<sharename>'? If the given path contains neither style of path prefix, the result is an empty string.
On Linux, ExtractFileDrive always returns a zero-length string.