vb打开服务器文件夹隐藏路径,VB获取系统各类文件夹路径

Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, ppidl As Long) As Long

Private Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath As String) As Long

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Const MAX_LEN = 200 '字符串最大长度

Const DESKTOP = &H0& '桌面

Const PROGRAMS = &H2& '程序集

Const MYDOCUMENTS = &H5& '我的文档

Const MYFAVORITES = &H6& '收藏夹

Const STARTUP = &H7& '启动

Const RECENT = &H8& '最近打开的文件

Const SENDTO = &H9& '发送

Const STARTMENU = &HB& '开始菜单

Const NETHOOD = &H13& '网上邻居

Const FONTS = &H14& '字体

Const SHELLNEW = &H15& 'ShellNew

Const APPDATA = &H1A& 'Application Data

Const PRINTHOOD = &H1B& 'PrintHood

Const PAGETMP = &H20& '网页临时文件

Const COOKIES = &H21& 'Cookies目录

Const HISTORY = &H22& '历史

Private Sub Form_Load()

Dim sTmp As String * MAX_LEN  '存放结果的固定长度的字符串

Dim nLength As Long  '字符串的实际长度

Dim pidl As Long  '某特殊目录在特殊目录列表中的位置

'*************************获得Windows目录**********************************

Length = GetWindowsDirectory(sTmp, MAX_LEN)

txtWin.Text = Left(sTmp, Length)

'*************************获得System目录***********************************

Length = GetSystemDirectory(sTmp, MAX_LEN)

txtSystem.Text = Left(sTmp, Length)

'*************************获得Temp目录***********************************

Length = GetTempPath(MAX_LEN, sTmp)

txtTemp.Text = Left(sTmp, Length)

'*************************获得DeskTop目录**********************************

SHGetSpecialFolderLocation 0, DESKTOP, pidl

SHGetPathFromIDList pidl, sTmp

txtDesktop.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得发送到目录**********************************

SHGetSpecialFolderLocation 0, SENDTO, pidl

SHGetPathFromIDList pidl, sTmp

txtSendTo.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得我的文档目录*********************************

SHGetSpecialFolderLocation 0, MYDOCUMENTS, pidl

SHGetPathFromIDList pidl, sTmp

txtDocument.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得程序集目录***********************************

SHGetSpecialFolderLocation 0, PROGRAMS, pidl

SHGetPathFromIDList pidl, sTmp

txtProgram.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得启动目录*************************************

SHGetSpecialFolderLocation 0, STARTUP, pidl

SHGetPathFromIDList pidl, sTmp

txtStart.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得开始菜单目录*********************************

SHGetSpecialFolderLocation 0, STARTMENU, pidl

SHGetPathFromIDList pidl, sTmp

txtStartMenu.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得收藏夹目录***********************************

SHGetSpecialFolderLocation 0, MYFAVORITES, pidl

SHGetPathFromIDList pidl, sTmp

txtFavorites.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'**********************获得最后打开的文件目录*******************************

SHGetSpecialFolderLocation 0, RECENT, pidl

SHGetPathFromIDList pidl, sTmp

txtRecent.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得网上邻居目录*********************************

SHGetSpecialFolderLocation 0, NETHOOD, pidl

SHGetPathFromIDList pidl, sTmp

txtNetHood.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得字体目录**********************************

SHGetSpecialFolderLocation 0, FONTS, pidl

SHGetPathFromIDList pidl, sTmp

txtFonts.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得Cookies目录**********************************

SHGetSpecialFolderLocation 0, COOKIES, pidl

SHGetPathFromIDList pidl, sTmp

txtCookies.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得历史目录**********************************

SHGetSpecialFolderLocation 0, HISTORY, pidl

SHGetPathFromIDList pidl, sTmp

txtHistory.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'***********************获得网页临时文件目录*******************************

SHGetSpecialFolderLocation 0, PAGETMP, pidl

SHGetPathFromIDList pidl, sTmp

txtPageTmp.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得ShellNew目录*********************************

SHGetSpecialFolderLocation 0, SHELLNEW, pidl

SHGetPathFromIDList pidl, sTmp

txtShellNew.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'***********************获得Application Data目录*****************************

SHGetSpecialFolderLocation 0, APPDATA, pidl

SHGetPathFromIDList pidl, sTmp

txtAppData.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

'*************************获得PrintHood目录*********************************

SHGetSpecialFolderLocation 0, PRINTHOOD, pidl

SHGetPathFromIDList pidl, sTmp

txtPrintHood.Text = Left(sTmp, InStr(sTmp, Chr(0)) - 1)

End Sub

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值