What I would like to do is when a users put in a USB Drive. My APP looks for it and finds it , Search \\usbdrive\myfile.dat. But I am missing the boat here. I never know what drive letter it will be? So can't put f:\ or h:\ cause I never know what letter it will be..
Announcement
Collapse
No announcement yet.
search all HD and USB Drives
Collapse
X
-
What happened when you tried...
Code:open "\\usbDrive\myfile.dat" FOR INPUT AS #6742
Then again, if your user has to insert the thing, he or she must be there and you could prompt them for a drive letter.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
-
-
You said you found "\\usbdrive" !!!
Try that in your OPEN - just like I typed it!!!Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
This code will return all drives present. Removable drives such as Floppy, CD-ROM/DVD or USB sticks are reported as DRIVE_REMOVABLE. I would check for all drives of this type but skip drive A:\, this would be acceptable in most cases.
Code:#Compile Exe #Dim All #Include "win32api.inc" Function PBMain Local i As Long Local sDrives As String Local szType As Asciiz * 128 sDrives = String$(GetLogicalDriveStrings(0, ByVal %Null), $Nul) GetLogicalDriveStrings Len(sDrives), ByVal StrPtr(sDrives) sDrives = RTrim$(sDrives, $Nul) For i = 1 To ParseCount(sDrives, $Nul) Select Case Const GetDriveType(Parse$(sDrives, $Nul, i)) Case %DRIVE_UNKNOWN: szType = "DRIVE_UNKNOWN" Case %DRIVE_NO_ROOT_DIR: szType = "DRIVE_NO_ROOT_DIR" Case %DRIVE_REMOVABLE: szType = "DRIVE_REMOVABLE" Case %DRIVE_FIXED: szType = "DRIVE_FIXED" Case %DRIVE_REMOTE: szType = "DRIVE_REMOTE" Case %DRIVE_CDROM: szType = "DRIVE_CDROM" Case %DRIVE_RAMDISK: szType = "DRIVE_RAMDISK" Case Else: szType = "Unknown type" End Select MsgBox Parse$(sDrives, $Nul, i) + $CrLf + "Drive Type: " + szType, , "Drive Number #" + Format$(i) Next i End Function
Comment
-
-
I took \\usbdrive\myfile.dat to mean a placeholder.
Comment
-
-
Silly me.
I mistook "My APP looks for it and finds it " as "My APP looks for it and finds it."
Guess I should have studied the posted code more carefully, huh?Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
I suppose Mark's first sentence wasn't 100% clear. People who do not have a good grasp of the API would not know where to start, thus no code will be shown.
In this case, the question was fairly easy. I even took the code from a previous post I located via POFFS:
Last edited by Kev Peel; 6 May 2008, 10:28 AM.
Comment
-
-
These might help you...
User to user discussions about the PB/Win (formerly PB/DLL) product line. Discussion topics include PowerBASIC Forms, PowerGEN and PowerTree for Windows.
Comment
-
Comment