Enhancing the SHBrowseForFolder API Function

WEBINAR: On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >

This code shows how to use the standard SHBrowseForFolder API function with a callback routine to set the initial directory.

Screen-shot

After reading the MSDN knowledge base article Q179378 "HOWTO: Browse for Folders from the Current Directory", I was able to figure out how to add a callback function that sets the starting directory and displays the currently selected path in the "Browse For Folder" dialog.

I used VB 6.0 (SP3) to compile this code. Should work in VB 5.0. However, because it uses the AddressOf operator this code will not work with versions below 5.0.

This code works in Window 95a so I assume it will work with later versions.


(Tested also under Win98/NT - works fine)


Usage:


    Dim folder as string
    '
    folder = BrowseForFolder(me, "Select A Directory", _
             "C:\startdir\anywhere")
    '
    If len(folder) = 0 then Exit Sub  'User Selected Cancel
    '

Download Zipped Files (5k)



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date