Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detect USB Drive
Message
 
To
21/02/2008 04:55:47
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01294633
Message ID:
01294779
Views:
19
This message has been marked as a message which has helped to the initial question of the thread.
>Hi All,
>
>Is there a way to know if my app is running from a USB or other removable drive?
>
>Thanks

Hi Jos,

You may try to get details from WinManagement LogicalDisk object. Properties like description, drivetype, filesystem and mediatype may give you some additional indications. Below is the piece of code from my utility program. Because it is extracted "piece", it may contain some stuff not actually needed to WMI LogicalDisk.
WMI = GETOBJECT("WinMgmts://.")
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
	 
		DO case
		case TYPE("oItem.name")="C"
			m.Item = ALLTRIM(.name)
		CASE pCursName="AdapterConfig" 		&& NetworkAdapterConfiguration
			* find it in NetworkAdapter cursor using Capture Property
			m.Item = "Unknown, #"+TRANSFORM(ia)
			SELECT NetworkAdapter
			LOCATE FOR ALLTRIM(property)="Caption" AND ALLTRIM(propvalue)==ALLTRIM(oItem.Caption)
			IF FOUND()
				m.Item = NetworkAdapter.item
			ENDIF
			SELECT (pCursName)
		otherwise
			m.Item = "Unknown, #"+TRANSFORM(ia)
		ENDCASE
		
		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"  	
&&What is A and how to handle it, I do not know at the moment
					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