Warm tip: This article is reproduced from stackoverflow.com, please click
delphi windows

Delphi SelectDirectory strange behaviour with network drive

发布于 2020-04-13 10:22:01

I have had a bug report from a client. My program uses the Delphi select directory function to allow him to choose a few directories used by the program, which are allowed to be on a network drive. Here's the relevant extract from the bug report:

When trying to change the directory the network drives were not shown in the dialog. When opening "Computer" in the browse menu only local drives were shown. The roundabout solution is to leave the dialog open, disconnect the network drive, and re-connect the network drive. It then appears in the dialog. When changing the next folder location it must be done all over again. I found out that the main technician has been doing this frequently as it seems to reset.

At first I thought that this must be Windows not picking up the directories, so I asked him to check that the network location on both computers (the client and the one with the network drive) was set to Work, to check that the drive was mapped on the client, to check that network discovery was turned on, and to check that he could see the drives OK in Explorer. He did, but the bug persists.

I've not turned up anything on google or in QC reports concerning this, the documentation for SelectDirExtOpts seems to suggest that network drives should 'just work'.

So my question: has anyone encountered anything resembling this before? Is it likely to be a Windows issue, or is it Delphi?

Many thanks.

Questioner
David Orpen
Viewed
68
Marjan Venema 2012-11-15 15:19

As long as you include that sdShowShares flag it should indeed just work.

If you look at the source of the SelectDirectory function you'll see that it isn't much more than setting things up for SHBrowseForFolder and reading the results.

SHBrowseForFolder is a Windows Shell API function:

function SHBrowseForFolder; external shell32 name 'SHBrowseForFolderW';

Delphi must interpreting the results it gets back from SHBrowseForFolder correctly, as the drives are shown correctly after reconnecting them. So I'd say it is a Windows problem on the client's machine.