VBiB/ACCB.net - Visual Basic in België | .net Ineta User Group  
(login to hide)
Hoofdmenu

Advertenties

Het Computer Winkeltje HCW


Evenementen

Tips en tricks
U bevindt zich > Tips en Tricks > VB 6 > Windows > Bestandsysteem > Map selecteren uit bestandsysteem
Ik wil een tip ingeven

Tip: Map selecteren uit bestandsysteem
Mibe - 10 Apr 2006 - 00:30

Naast een bestand hebt u soms nood om een map te selecteren uit het bestandsysteem van windows. Met deze tip kunt u dit in VB6 perfect uitvoeren -Oorsprong van deze tip staat bovenaan de code-
Code:


'FORM

'--------------------------------------------------------------
' Copyright ©1996-2001 VBnet, Randy Birch, All Rights Reserved.
' Terms of use http://www.mvps.org/vbnet/terms/pages/terms.htm
'--------------------------------------------------------------


Option Explicit

Private Sub Command1_Click()

  Dim bi As BROWSEINFO
  Dim pidl As Long
  Dim path As String
  Dim pos As Integer

  Label1.Caption = ""

'Fill the BROWSEINFO structure with the
'needed data. To accomodate comments, the
'With/End With sytax has not been used, though
'it should be your 'final' version.

'hwnd of the window that receives messages
'from the call. Can be your application
'or the handle from GetDesktopWindow().
  bi.hOwner = Me.hWnd

'Pointer to the item identifier list specifying
'the location of the "root" folder to browse from.
'If NULL, the desktop folder is used.
  bi.pidlRoot = 0&

'message to be displayed in the Browse dialog
  bi.lpszTitle = "Select your destination directory"

'the type of folder to return.
  bi.ulFlags = BIF_RETURNONLYFSDIRS

'show the browse for folders dialog
  pidl = SHBrowseForFolder(bi)

'the dialog has closed, so parse & display the
'user's returned folder Selection contained in pidl
  path = Space$(MAX_PATH)

  If SHGetPathFromIDList(ByVal pidl, ByVal path) Then
     pos = InStr(path, Chr$(0))
     Label1.Caption = Left(path, pos - 1)
  End If

  Call CoTaskMemFree(pidl)

End Sub

Private Sub Form_Load()

End Sub

'MODULE

'--------------------------------------------------------------
' Copyright ©1996-2001 VBnet, Randy Birch, All Rights Reserved.
' Terms of use http://www.mvps.org/vbnet/terms/pages/terms.htm
'--------------------------------------------------------------


Public Type BROWSEINFO
   hOwner           As Long
   pidlRoot         As Long
   pszDisplayName   As String
   lpszTitle        As String
   ulFlags          As Long
   lpfn             As Long
   lParam           As Long
   iImage           As Long
End Type

Public Const BIF_RETURNONLYFSDIRS = &H1
Public Const BIF_DONTGOBELOWDOMAIN = &H2
Public Const BIF_STATUSTEXT = &H4
Public Const BIF_RETURNFSANCESTORS = &H8
Public Const BIF_BROWSEFORCOMPUTER = &H1000
Public Const BIF_BROWSEFORPRINTER = &H2000
Public Const MAX_PATH = 260

Public Declare Function SHGetPathFromIDList _
   Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
  (ByVal pidl As Long, _
   ByVal pszPath As String) As Long

Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
   Alias "SHBrowseForFolderA" _
  (lpBrowseInfo As BROWSEINFO) As Long

Public Declare Sub CoTaskMemFree Lib "ole32.dll" _
   (ByVal pv As Long)

3051 x gelezen

Commentaar
U dient ingelogd te zijn om commentaar te posten.
 

Er zijn in totaal 102 tips gepost.

 

 
Postnuke - ADODB Database - PHP 4/5 - pnPhpBB2 - Hosting bij Openminds
Met dank aan Jürgen voor de jarenlange inzet van visualbasic.be (anno 21-12-2000)
vbib.be gestart op 1/03/06 (extra vanaf 1/09: vbnet.be en vbdotnet.be)
VBiB is gerelateerd met wintips.be

Nieuwsbrief RSS Feed: backend.php