Module1.bas
资源名称:Share_win.rar [点击查看]
上传用户:wxknfb
上传日期:2022-08-10
资源大小:4k
文件大小:2k
源码类别:
网络编程
开发平台:
Visual Basic
- Attribute VB_Name = "Module1"
- Option Explicit
- '****************************************************************************
- '人人为我,我为人人
- '枕善居汉化收藏整理
- '发布日期:05/03/29
- '描述:一个共享远程文件夹源码示例
- '网站:http://www.mndsoft.com
- 'e-mail:mnd@mndsoft.com
- '****************************************************************************
- 'typedef struct _browseinfo {
- ' HWND hwndOwner; // see below
- ' LPCITEMIDLIST pidlRoot; // see below
- ' LPSTR pszDisplayName; // see below
- ' LPCSTR lpszTitle; // see below
- ' UINT ulFlags; // see below
- ' BFFCALLBACK lpfn; // see below
- ' LPARAM lParam; // see below
- ' int iImage; // see below
- '} BROWSEINFO, *PBROWSEINFO, *LPBROWSEINFO;
- 'WINSHELLAPI BOOL WINAPI SHGetPathFromIDList(
- ' LPCITEMIDLIST pidl,
- ' LPSTR pszPath
- ' );
- 'WINSHELLAPI LPITEMIDLIST WINAPI SHBrowseForFolder(
- ' LPBROWSEINFO lpbi
- ' );
- Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Boolean
- Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BROWSEINFO) As Long
- Private Type BROWSEINFO
- hWndOwner As Long
- pidlRoot As Long ' typedef struct LPCITEMIDLIST
- pszDisplayName As String
- lpszTitle As String
- ulFlags As Long
- lpfn As Long 'BrowseCallbackProc or NULL
- lParam As Long
- iImage As Integer
- End Type
- Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
- Private Const BIF_BROWSEFORPRINTER As Long = &H2000
- Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
- Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
- Private Const BIF_RETURNONLYFSDIRS As Long = &H1
- Private Const BIF_STATUSTEXT As Long = &H4
- Private Const BIF_RETURNFSANCESTORS As Long = &H8
- Private Const MAX_PATH As Long = 260
- Public Function SetFolder(hwnd As Long, Titulo As String) As String
- Dim shb As BROWSEINFO
- Dim res As Long, res1 As Boolean
- Dim s As String
- shb.hWndOwner = hwnd
- shb.lpszTitle = Titulo & vbNullChar
- shb.pszDisplayName = vbNullString
- shb.ulFlags = BIF_RETURNONLYFSDIRS 'only folder
- shb.lpfn = 0&
- shb.iImage = 1
- res = SHBrowseForFolder(shb)
- If res <> 0 Then
- s = Space(MAX_PATH + 1)
- res1 = SHGetPathFromIDList(res, s)
- DoEvents
- If res1 = 1 Then SetFolder = s
- End If
- End Function