D
dev
Hello,
How can the following code be converted to VB.Net? I am mostly interested
in how to handle the StrPtr calls in the function.
Private Declare Function PathRelativePathToW Lib "shlwapi.dll" _
(ByVal pszPath As Long, _
ByVal pszFrom As Long, _
ByVal dwAttrFrom As Long, _
ByVal pszTo As Long, _
ByVal dwAttrTo As Long) As Boolean
Public Function GetRelativePath(ByVal sFromDirectory As String, _
ByVal sToFile As String) As String
Dim sRelativePath As String
Dim bResult As Boolean
Const MAX_PATH As Long = 260
sRelativePath = Space(MAX_PATH)
' Set "Attr" to vbDirectory for directories and 0 for files
bResult = PathRelativePathToW(StrPtr(sRelativePath),
StrPtr(sFromDirectory), _
vbDirectory, StrPtr(sToFile), 0)
If bResult Then
GetRelativePath = Left(sRelativePath, InStr(sRelativePath,
Chr(0)) -1)
End If
End Function
TIA,
Steve
How can the following code be converted to VB.Net? I am mostly interested
in how to handle the StrPtr calls in the function.
Private Declare Function PathRelativePathToW Lib "shlwapi.dll" _
(ByVal pszPath As Long, _
ByVal pszFrom As Long, _
ByVal dwAttrFrom As Long, _
ByVal pszTo As Long, _
ByVal dwAttrTo As Long) As Boolean
Public Function GetRelativePath(ByVal sFromDirectory As String, _
ByVal sToFile As String) As String
Dim sRelativePath As String
Dim bResult As Boolean
Const MAX_PATH As Long = 260
sRelativePath = Space(MAX_PATH)
' Set "Attr" to vbDirectory for directories and 0 for files
bResult = PathRelativePathToW(StrPtr(sRelativePath),
StrPtr(sFromDirectory), _
vbDirectory, StrPtr(sToFile), 0)
If bResult Then
GetRelativePath = Left(sRelativePath, InStr(sRelativePath,
Chr(0)) -1)
End If
End Function
TIA,
Steve