-=TsA=- писал(а):И еще, относительно вашего спора нужен относительный путь из любого каталога, а не только из вложенного.
А какая функция выполняет обратную задачу?
-=TsA=- писал(а):А какая функция выполняет обратную задачу?
Private Declare Function PathRelativePathTo Lib "shlwapi.dll" Alias "PathRelativePathToA" (ByVal pszPath As String, ByVal pszFrom As String, ByVal dwAttrFrom As Long, ByVal pszTo As String, ByVal dwAttrTo As Long) As Long
Parameters
pszPath
[out] Pointer to a string that receives the relative path. This buffer is assumed to be at least MAX_PATH characters in size.
pszFrom
[in] Pointer to a null-terminated string of maximum length MAX_PATH that contains the path that defines the start of the relative path.
dwAttrFrom
[in] File attributes of pszFrom. If this value contains FILE_ATTRIBUTE_DIRECTORY, pszFrom is assumed to be a directory; otherwise, pszFrom is assumed to be a file.
pszTo
[in] Pointer to a null-terminated string of maximum length MAX_PATH that contains the path that defines the endpoint of the relative path.
dwAttrTo
[in] File attributes of pszTo. If this value contains FILE_ATTRIBUTE_DIRECTORY, pszTo is assumed to be directory; otherwise, pszTo is assumed to be a file.
Return Value
Returns TRUE if successful, or FALSE otherwise.
Remarks
This function takes a pair of paths and generates a relative path from one to the other. The paths do not have to be fully-qualified, but they must have a common prefix, or the function will fail and return FALSE.
For example, let the starting point, pszFrom, be "c:\FolderA\FolderB\FolderC", and the ending point, pszTo, be "c:\FolderA\FolderD\FolderE". PathRelativePathTo will return the relative path from pszFrom to pszTo as: "..\..\FolderD\FolderE". You will get the same result if you set pszFrom to "\FolderA\FolderB\FolderC" and pszTo to "\FolderA\FolderD\FolderE". On the other hand, "c:\FolderA\FolderB" and "a:\FolderA\FolderD do not share a common prefix, and the function will fail. Note that "\\" is not considered a prefix and is ignored. If you set pszFrom to "\\FolderA\FolderB", and pszTo to "\\FolderC\FolderD", the function will fail.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 10