Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GETDIR()
Message
From
19/10/1998 21:25:27
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00147889
Message ID:
00148350
Views:
19
>I'm using the GETDIR() to get a directory I put in the registry for certain functions.
>The problem I have is that GETDIR() doesn't see the network. Is there any other function that could help me with this?
>

There's an entry in the FAQ on an Enhanced GETDIR() that relies on the Shell.Application object to provide a browser interface, you might want to look at that. The following is my current production code based on it:
FUNCTION EnhancedGetDir
LPARAMETERS cDialogTitle, cStartingFolder, nBrowseFlags
*  Select a directory using the default browser dialog
IF TYPE('cDialogTitle') # 'C'
	cDialogTitle = 'Please select a folder:'
ENDIF
IF TYPE('cStartingFolder') # 'C'
	cStartingFolder = ''
ENDIF
IF TYPE('nBrowseFlags') # 'N'
	* uses BROWSEINFO structure ulFlags values
	* by default, set BIF_RETURNONLYFSDIRS (1) and BIF_EDITBOX (16) and BIF_VALIDATE
	* to limit to returning directories, provide an edit box to let user enter a path,
	* and validate manually-entered paths
	*
	* ulFlags values:
	*	BIF_RETURNONLYFSDIRS	1
	*	BIF_DONTGOBELOWDOMAIN	2
	*	BIF_STATUSTEXT			4
	*	BIF_RETURNFSANCESTORS	8
	*	BIF_EDITBOX				0x10
	*	BIF_VALIDATE			0x20
	*	BIF_BROWSEFORCOMPUTER	0x1000
	*	BIF_BROWSEFORPRINTER	0x2000
	*	BIF_BROWSEFOREVERYTHING	0x4000
	nBrowseFlags = 32 + 16 + 1
ENDIF
LOCAL oBrowseObject, cPathToReturn, oShellObj
oShellObj = CREATEOBJ('Shell.Application')
cPathToReturn = NULL
*	Get a Folder object
oBrowseObject = oShellObj.BrowseForFolder(0, ;
											cDialogTitle, ;
											nBrowseFlags, ;
											cStartingFolder)
*	If oBrowseObject is returned, it'll be a Folder object
*	If not, no folder was selected
*
*	Check to make certain that there's a ParentFolder.Items collection
*	If not, a Windows SpecialFolder was selected, probably Desktop unless
*	the default ulFlags are not used
*
*	Before I used the Items collection of the Folder object
*	to get a path;  it doesn't work if the directory is empty.
*	Instead, spin through the Items collection of the Parent
*	Folder and locate the item whose name matches the
*	Title property of the Folder object;  return that path
DO CASE
CASE TYPE('oBrowseObject') # 'O'
	*	Nothing selected - return NULL
CASE TYPE('oBrowseObject.ParentFolder.Items') = 'U'	
	*	SpecialFolder selected;  you could resolve via a
	*	Wscript.Shell.SpecialFolders object, searching for
	*	oBrowseObject.Title, but there's no guarentee that it
	*	will return a usable folder - I'll return NULL instead
OTHERWISE
	*	Find the FolderItem of ParentFolder matching oBrowseObject.Title
	*	and return the FolderItem.Path value
   	FOR EACH Item IN oBrowseObject.ParentFolder.Items
       	IF Item.Name == oBrowseObject.Title
           	cPathToReturn = Item.Path
            EXIT
   	    ENDIF
    ENDFOR
ENDCASE
RETURN cPathToReturn
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform