Convert a mapped drive to a full UNC path | |||
| |||
The format for a UNC path is \servervolumedirectoryfile and is not case-sensitive. For example: \Shared1_svrShared1WGroupsNetworkOrders.xls Rather than describe the location of a file or directory by drive letter, the Network Group will typically communicate a UNC path to describe the actual location of a file or directory. Windows drive letter mappings are arbitrary, whereas a UNC path is specific and applies to all operating systems. Note: The UNC method started with the UNIX operating system. UNIX uses the forward-slash character as a path separator. Many network services (ex. FTP) have their origins in the UNIX operating system, so they use forward-slashes instead of the backslashes that DOS/Windows uses. It is important to recognize this distinction when using these services. Usage: UNCLabel.Caption := ConvertToUNCPath(ExtractFileDrive(Edit1.Text)) ; Followings are the source can get UNC Path. function ConvertToUNCPath(MappedDrive: string) : string; var RemoteString : array[0..255] of char; lpRemote : PChar; StringLen : Integer; begin lpRemote := @RemoteString; StringLen := 255; If WNetGetConnection(Pchar(ExtractFileDrive(MappedDrive)) , lpRemote, StringLen) = NO_ERROR Then Result := RemoteString Else Result:=''; // Alternatively return an errorcode, Raise an exception or something like end; end; Tags: Delphi File I/O Status Check Is Audio CD Uniform Naming Convention Universal Naming Convention WNetGetConnection | |||
| |||
| |||
Login for comment |