From: Karl E. Peterson on
Bob Butler laid this down on his screen :
> "Dave O." <nobody(a)nowhere.com> wrote in message
> news:evkWYzRHLHA.5684(a)TK2MSFTNGP02.phx.gbl...
>> Easy enough with some help from the API.
>> First you need GetLogicalDriveStrings which will return a list of all
>> drives on the PC, you split this in whatever way you like.
>> The use GetDriveType on each returned letter to check that it's a volume on
>> a local hard drive.
>
> I've always just looped A-Z and used GetDriveType to skip ones that don't
> exist. I've never found a good reason to use GetLogicalDriveStrings. Apart
> from maybe saving a few milliseconds is there anything else it provides?

Moral absolution for those who feel tainted by error trapping.

--
..NET: It's About Trust!
http://vfred.mvps.org


From: Tony Toews on
On Tue, 6 Jul 2010 13:12:23 -0700, "Bob Butler"
<bob_butler(a)cox.invalid> wrote:

>> Is there a difference if some drive letters aren't connected to a
>> network? Possibly GetLogicalDriveStrings would ignore those.
>
>That's the point. GetLogicalDriveLetters returns just those drives in use
>but it's just as easy to check all 26 letters and ignore those that return
>'no drive found' as it is to ask for the list of valid drives and then
>process only them (and still having to check in case one disconnects while
>processing the list).
>
>Getting the list of drives is probably the "right" way to do it but I've
>just never bothered.

I forgot to completely explain my though processes. (Assuming there
was any thought involved.) If the drive letter points to a non
connected network resource then about two seconds is likely wasted
while Windows does its things. Or so I've noticed on my system.

So if GetLogicalDriveLetters ignores those disconnected network
resources that would be a better solution.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
From: Bob Butler on

"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:i10c84$qgb$1(a)news.eternal-september.org...
> Bob Butler laid this down on his screen :
>> "Dave O." <nobody(a)nowhere.com> wrote in message
>> news:evkWYzRHLHA.5684(a)TK2MSFTNGP02.phx.gbl...
>>> Easy enough with some help from the API.
>>> First you need GetLogicalDriveStrings which will return a list of all
>>> drives on the PC, you split this in whatever way you like.
>>> The use GetDriveType on each returned letter to check that it's a volume
>>> on a local hard drive.
>>
>> I've always just looped A-Z and used GetDriveType to skip ones that don't
>> exist. I've never found a good reason to use GetLogicalDriveStrings.
>> Apart from maybe saving a few milliseconds is there anything else it
>> provides?
>
> Moral absolution for those who feel tainted by error trapping.

except you still need to check since a drive could be disconnected between
the call to GetLogicalDriveStrings and GetDriveType

If it does avoid network drives that have lost the connection then that
would be a benefit but I'd be surprised if it did since to know that it'd
have to test them.


From: Karl E. Peterson on
Bob Butler laid this down on his screen :
> "Karl E. Peterson" <karl(a)exmvps.org> wrote...
>> Bob Butler laid this down on his screen :
>>> "Dave O." <nobody(a)nowhere.com> wrote in message
>>> news:evkWYzRHLHA.5684(a)TK2MSFTNGP02.phx.gbl...
>>>> Easy enough with some help from the API.
>>>> First you need GetLogicalDriveStrings which will return a list of all
>>>> drives on the PC, you split this in whatever way you like.
>>>> The use GetDriveType on each returned letter to check that it's a volume
>>>> on a local hard drive.
>>>
>>> I've always just looped A-Z and used GetDriveType to skip ones that don't
>>> exist. I've never found a good reason to use GetLogicalDriveStrings.
>>> Apart from maybe saving a few milliseconds is there anything else it
>>> provides?
>>
>> Moral absolution for those who feel tainted by error trapping.
>
> except you still need to check since a drive could be disconnected between
> the call to GetLogicalDriveStrings and GetDriveType

That was sorta TIC, there. <g>

I suppose one benefit might be in that you could then ask the user
which drives to check. Or know which drive letters were unavailable.
But it'd all come down to making life easier for the user, not the
developer, yeah.

> If it does avoid network drives that have lost the connection then that would
> be a benefit but I'd be surprised if it did since to know that it'd have to
> test them.

I can't imagine any savings there, either, unless the list is solely
for the purpose I suggest -- asking the user which drive(s) to select.

--
..NET: It's About Trust!
http://vfred.mvps.org


From: LondonLad on
Hi
Thank you all for your posts just to let you know I was not including
network drives sorry should have said that in my post.
An extra thank you to Larry Serflaten for his code snippet I have tested it
in a test project and it works fine. I will now need include in actual
project WIP.
Regards

Ron

"Larry Serflaten" wrote:

>
> "LondonLad" <LondonLad(a)discussions.microsoft.com> wrote
> > Hi
> > Finding all files with named extn on a single drive I have no problems with
> > , but can someone give me a link to helpful code so I can find all files with
> > named extn on all drives on my computer.
>
> This may or may not suit your needs, you decide....
>
> Add a command button to a new form and paste in the code below to
> try it out....
>
> LFS
>
> -------------------
>
> Private Sub Command1_Click()
> Dim WMI, QRY, ITEM
> On Error Resume Next
> Set WMI = GetObject("winmgmts://./root/cimv2")
> If Err.Number Then
> MsgBox "WMI not available."
> Else
> QRY = "SELECT Name FROM Win32_LogicalDisk WHERE Description = 'Local Fixed Disk'"
> For Each ITEM In WMI.ExecQuery(QRY, "WQL", &H30)
> Searching ITEM.Name
> Next
> End If
> End Sub
>
> Sub Searching(DriveName As String)
> 'your search code goes here
> MsgBox "Searching for files on drive " & DriveName, vbOKOnly, "Search Mode"
> End Sub
>
>
> .
>