加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

VB6获取快捷方式lnk文件的指向绝对路径

发布时间:2020-12-16 22:24:25 所属栏目:大数据 来源:网络整理
导读:就是直接艹lnk的文件结构罢了。 Private Declare Sub GetMem2 Lib "msvbvm60" (ByVal Ptr As Long,RetVal As Integer)Private Declare Sub GetMem4 Lib "msvbvm60" (ByVal Ptr As Long,RetVal As Long)Private Declare Sub MoveMemory Lib "msvbvm60" Alias

就是直接艹lnk的文件结构罢了。

Private Declare Sub GetMem2 Lib "msvbvm60" (ByVal Ptr As Long,RetVal As Integer)
Private Declare Sub GetMem4 Lib "msvbvm60" (ByVal Ptr As Long,RetVal As Long)
Private Declare Sub MoveMemory Lib "msvbvm60" Alias "__vbaCopyBytesZero" (ByVal Length As Long,ByVal Dst As Long,ByVal Src As Long)
Private Declare Function lstrlenA& Lib "kernel32" (ByVal lpString&)
Private Function QueryShortcutFilePath$(ByVal lnkFile$)
Dim pFlag&,pFileInfo&,pFilePath&,pSHHeadLength%,strFilePath$,lpBuffer() As Byte
Open lnkFile For Binary Access Read As #1
ReDim lpBuffer(LOF(1) - 1)
Get #1,lpBuffer
Close #1
GetMem4 VarPtr(lpBuffer(0)),pFlag
If pFlag = &H4C Then
GetMem2 VarPtr(lpBuffer(76)),pSHHeadLength
pFileInfo = &H4C + pSHHeadLength + 2
If lpBuffer(pFileInfo + 8) = 1 Then '//local file
If lpBuffer(pFileInfo + 40) = 16 Then  '//test ok
pFilePath = pFileInfo + 44
pFilePath = pFilePath + lstrlenA(VarPtr(lpBuffer(pFilePath))) + 1 '// jump volume label
If lstrlenA(VarPtr(lpBuffer(pFilePath))) > 0 Then
strFilePath = Space$(260)
MoveMemory lstrlenA(VarPtr(lpBuffer(pFilePath))) + 1,StrPtr(strFilePath),VarPtr(lpBuffer(pFilePath))
strFilePath = LeftB$(strFilePath,lstrlenA(StrPtr(strFilePath)))
QueryShortcutFilePath = StrConv(strFilePath,vbUnicode)
End If
End If
End If
End If
End Function

Private Sub Form_Load()
Dim strCmd$
strCmd = Replace$(Command$,Chr$(34),vbNullString)
Me.Caption = QueryShortcutFilePath(strCmd)
End Sub

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读