Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is path selected the USB pen drive port?
Message
From
27/09/2006 09:14:45
 
 
To
27/09/2006 07:07:13
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01157437
Message ID:
01157464
Views:
20
It just dawned on me that you should be able to do this more accurately using GETDRIVETYPE, CREATEFILE, and DEVICEIOCONTROL api...

I am currently working with USB io and found a handy reference:

http://www.delcom-eng.com/downloads/USBPRGMNL.pdf


Here is some code using C# you may be able to convert to vfp (it uses the setup api):

http://www.codeproject.com/useritems/usbeject.asp


You can check the registry. All usb devices have an item under:

HKEY_LOCAL_MACHINE\CurrentControlSet\Enum\USB\[Vid_...]

also there is usually an entry created for USB Storage Devices:

HKEY_LOCAL_MACHINE\CurrentControlSet\Enum\USBSTOR\...

Do you have one installed? What does it show when you run this code?
* This program enumerates all drives on a Win32 system and
* displays a message box containing the drive letters and
* types of all logical drives on the system.
*

* Constants for drive types.
#DEFINE DRIVE_UNKNOWN 0
#DEFINE DRIVE_NO_ROOT_DIR 1
#DEFINE DRIVE_REMOVABLE 2
#DEFINE DRIVE_FIXED 3
#DEFINE DRIVE_REMOTE 4
#DEFINE DRIVE_CDROM 5
#DEFINE DRIVE_RAMDISK 6
#DEFINE CR CHR(13)

DECLARE INTEGER GetLogicalDrives IN Win32API
DECLARE INTEGER GetDriveType IN Win32API STRING RootPath

PRIVATE lcDrivestring, lcDriveRoot, liDrivelist, lcDrives, i
lcDrives = ""

* GetLogicalDrives returns a 32-bit value containing a list of
* available drives. If the specific bit is ON, the drive letter
* corresponding to that position exists.
liDrivelist = GetLogicalDrives()
*   return liDrivelist

* Check each of the bits
PRIVATE ARRAY ladrives(1,2)
IF UPPER(TYPE('ladrives(1,1)'))<>"L"
	DIMENSION ladrives(1,2)
	ladrives(1,1)=.F.
	ladrives(1,2)=.F.
ENDIF

PRIVATE lcFloppy, lnFloppy
lnFloppy=1
lcFloppy="A:\"

FOR i = 0 TO 31
	IF BITTEST(liDrivelist, i)
		* If the 0th bit is ON, that means drive 'A:',
		* the 2nd bit is 'C:", etc.
		lcDriveRoot = CHR(65 + i) + ":\"
		* Perform a GetDriveType to determine if it is a floppy, CD, etc.
		lcDrivetype = GetDriveType(lcDriveRoot)
		DO CASE
			CASE lcDrivetype = DRIVE_UNKNOWN
				lcDrivestring = "Cannot be determined"
			CASE lcDrivetype = DRIVE_NO_ROOT_DIR
				lcDrivestring = "Root directory does not exist"
			CASE lcDrivetype = DRIVE_REMOVABLE
				lcDrivestring = "Floppy/removable drive"
			CASE lcDrivetype = DRIVE_FIXED
				lcDrivestring = "Hard drive/nonremovable drive"
			CASE lcDrivetype = DRIVE_REMOTE
				lcDrivestring = "Remote/Network drive"
			CASE lcDrivetype = DRIVE_CDROM
				lcDrivestring = "CD-ROM drive"
			CASE lcDrivetype = DRIVE_RAMDISK
				lcDrivestring = "RAM disk"
		ENDCASE
		lcDrives = lcDrives + lcDriveRoot + " " + lcDrivestring + CR
		IF UPPER(TYPE('laDrives(ALEN(laDrives,1),1)'))="L"
			laDrives(ALEN(laDrives,1),1)=lcDriveRoot
			laDrives(ALEN(laDrives,1),2)=lcDriveString
		ELSE
			DIMENSION laDrives(ALEN(laDrives,1)+1,2)
			laDrives(ALEN(laDrives,1),1)=lcDriveRoot
			laDrives(ALEN(laDrives,1),2)=lcDriveString
		ENDIF
	ENDIF
NEXT
=ASORT(laDrives)
*lnfloppy=ASCAN(laDrives,'Floppy')-1
=MESSAGEBOX(lcDrives, 0 + 64 + 0)
RETURN
>Hi,
>
>I've created a litttle utitility to backup to any drive or path. Is there any way to check if the path selected is the USB pen drive port?
>
>Thanks
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform