Starting in Windows Vista, Microsoft implemented a new common dialog control for selecting files or folders known as the Common Item Dialog.
Unlike the earlier common dialog window however, this one isn't accessible through a simple Windows API call. Instead, it requires a COM implementation, which makes it a bit trickier to access from PowerBuilder. Fortunately, this StackOverflow posting provided an example of using the dialog from within C#. Once we have that, it was only a matter of tweaking it slightly to remove it's reliance on Windows Forms classes and then creating a COM visible assembly from it that we can then invoke from a PowerBuilder Classic Win32 target via OLE Automation or from one of the .Net target types in PowerBuilder Classic or PowerBuilder.Net by adding the assembly as a reference. The resulting C# code looks like the following, and the assembly is then made COM Visible and signed so it can be added to the Global Assembly Cache if needed.
Once you have the assembly, if you want to call it from a PowerBuilder Classic Win32 application you'll need to take the following steps.
1. Run regasm on it to create the registry entries that PowerBuilder needs to use it via OLE Automation. If you are on a 64 bit system, you'll want to generate a reg file using the /regfile: argument and then edit it so that the entries are created in the Wow6432Node/CLSID portoin of the registry rather than the default (64bit) CLSID section.
2. Run gacutil on it to load it into the Global Assembly Cache (GAC).
To call it from a PowerBuilder Classic Win32 application, you would then only need to do the following:
This particular example looks for the user to select a folder. Slight modification of the sample would allow you to select items instead.
The sample code (both C# and PowerBuilder Classic) is available on my Goggle Drive. Simply run the FolderBrowser2_32.reg file on a 32 bit system or the FolderBrowser2_64.reg file on a 64 bit system to add the registry entries from REGASM and then run gacutil on the assembly to add it to the GAC. At that point the PowerBuilder Classic demo should run for you and you'll see a window like shown above.