vb6 获取桌面的地址

很多电脑都用了像360的c盘搬家之类的功能,所以windows的桌面文件夹地址不确定,再次求大神指点如何获取这个文件夹的位置,是vb6的... 很多电脑都用了像360的c盘搬家之类的功能,所以windows的桌面文件夹地址不确定,再次求大神指点如何获取这个文件夹的位置,是vb6的 展开
 我来答
popmoon
2014-02-14 · TA获得超过9994个赞
知道大有可为答主
回答量:4464
采纳率:30%
帮助的人:3550万
展开全部
'桌面路径
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
jmyzb
2014-02-15
知道答主
回答量:56
采纳率:0%
帮助的人:17.1万
展开全部
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
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式