vb6 获取桌面的地址
很多电脑都用了像360的c盘搬家之类的功能,所以windows的桌面文件夹地址不确定,再次求大神指点如何获取这个文件夹的位置,是vb6的...
很多电脑都用了像360的c盘搬家之类的功能,所以windows的桌面文件夹地址不确定,再次求大神指点如何获取这个文件夹的位置,是vb6的
展开
展开全部
'桌面路径
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command7_Click()
'桌面路径
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
Dim A As String
If lSize > 0 Then
A = Left$(sBuffer, lSize)
A = Left(A, Len(A) - 1)
LabelPath.Caption = "c:\Documents and settings\" & A & "\desktop"'这里显示路径
Else
A = vbNullString
End If
End Sub
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command7_Click()
'桌面路径
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
Dim A As String
If lSize > 0 Then
A = Left$(sBuffer, lSize)
A = Left(A, Len(A) - 1)
LabelPath.Caption = "c:\Documents and settings\" & A & "\desktop"'这里显示路径
Else
A = vbNullString
End If
End Sub
展开全部
Private Type SHITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Sub Form_Load()
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Dim R As Long, Path As String
Dim IDL As ITEMIDLIST
R = SHGetSpecialFolderLocation(100, 0, IDL)
If R = 0 Then
Path = Space(255)
R = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path)
R = InStr(Path, vbNullChar)
If R > 0 Then
Path = Left(Path, R - 1)
End If
Else: Path = ""
End If
Caption = Path
End Sub
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Sub Form_Load()
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Dim R As Long, Path As String
Dim IDL As ITEMIDLIST
R = SHGetSpecialFolderLocation(100, 0, IDL)
If R = 0 Then
Path = Space(255)
R = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path)
R = InStr(Path, vbNullChar)
If R > 0 Then
Path = Left(Path, R - 1)
End If
Else: Path = ""
End If
Caption = Path
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询