Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining valid drives
Message
 
To
08/12/2006 13:38:36
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01176193
Message ID:
01176203
Views:
8
>Hi all,
>
>I want to set something up on a form that will allow the user to select from a list of valid drives on the system (C:, F:, etc.). I'd like to do this with a listbox or a spinner.
>
>How can I determine what the valid drives would be? Once that's determined, how do I get a list of the valid folders on that drive?
>
>Thanks!
>
>John


One of the solutions:

Use shellexec to run NET USE > c:\report.log. Then work with LOG file.

Another solution:
WMI = GetObject("WinMgmts:")
*Logical Disk
objs = WMI.InstancesOf("Win32_LogicalDisk")
DO iCollect with objs, "LogicalDisk"
objs=null

*---------------------------------------
PROCEDURE iCollect
LPARAMETERS pObject, pCursName

LOCAL ia, oItem 

CREATE curs (pCursName) (Item c(90),property c(55), proptype c(1),propvalue c(150), valueiflong M)
ia=0
FOR EACH oItem IN pObject
	ia=ia+1
	 WITH oItem
	 
		m.Item = ALLTRIM(.name)		
		m.valueiflong=""
		IF .Properties_.Count >0
			FOR EACH oProperty IN .Properties_
				m.property=ALLTRIM(oproperty.Name)
				m.proptype=TYPE("oproperty.Value")
				IF m.proptype#"A"  	
					m.propvalue=ALLTRIM(TRANSFORM(oproperty.Value))
					IF LEN(m.propvalue)>150
						m.valueiflong=m.propvalue
						m.propvalue=""
					ENDIF
				ELSE
					m.propvalue="?????????"
				endif
				INSERT INTO (pCursName) FROM memvar
			ENDFOR
		ELSE
			INSERT INTO (pCursName) (Item) VALUES (m.Item)
		ENDIF
	ENDWITH
	
ENDFOR

RETURN
*------------------------------
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform