Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #181
| From | GS <gs@somewhere.net> |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc, microsoft.public.vb.general.discussion |
| Subject | Re: Need help with writing drive property: Possible solution |
| Date | 2011-05-22 16:26 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <irbrbe$hjl$1@dont-email.me> (permalink) |
| References | (1 earlier) <ir9gm7$mgl$1@dont-email.me> <ir9i00$t2k$1@dont-email.me> <ir9vnu$veo$1@dont-email.me> <ira8ut$6u3$1@dont-email.me> <irb2l7$ds6$1@dont-email.me> |
Cross-posted to 2 groups.
Mayayana submitted this idea :
> I found the answer, but it's very ugly:
I guess some people just like doing things the hard way. Here's how I
did it...
Sub List_AllDrives()
' Lists all drives as <Index>:<DriveLetter>
Dim oWMI, vDrives, vDrv, aDrvs(), s1, s2, i, iPos
On Error GoTo ErrorExit
Set oWMI = _
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set vDrives = _
oWMI.ExecQuery("Select * from Win32_LogicalDiskToPartition")
i = 0
For Each vDrv In vDrives
s1 = vDrv.Antecedent: iPos = InStr(1, s1, "#")
s1 = Mid$(s1, iPos + 1, InStr(1, s1, ",") - (iPos + 1)) '//index
s2 = vDrv.Dependent: iPos = InStr(1, s2, "=")
s2 = Mid$(s2, iPos + 2, 1) '//drive letter
ReDim Preserve aDrvs(0 To i): aDrvs(i) = s1 + ":" + s2: i = i + 1
Next
' For i = LBound(aDrvs) To UBound(aDrvs): Debug.Print aDrvs(i): Next
ErrorExit:
Set oWMI = Nothing: Set vDrives = Nothing
End Sub 'List_AllDrives
Now, all I have to do is use the index to associate drive letter to
DiskDrive!
--
Garry
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar
Need help with writing drive property GS <gs@somewhere.net> - 2011-05-21 16:54 -0400
Re: Need help with writing drive property "Mayayana" <mayayana@invalid.nospam> - 2011-05-21 19:10 -0400
Re: Need help with writing drive property GS <gs@somewhere.net> - 2011-05-21 19:35 -0400
Re: Need help with writing drive property "Mayayana" <mayayana@invalid.nospam> - 2011-05-21 23:27 -0400
Re: Need help with writing drive property GS <gs@somewhere.net> - 2011-05-22 00:49 -0400
Re: Need help with writing drive property GS <gs@somewhere.net> - 2011-05-22 00:58 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 02:07 -0400
Re: Need help with writing drive property: Possible solution "MikeD" <nobody@nowhere.edu> - 2011-05-22 09:02 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 14:29 -0400
Re: Need help with writing drive property: Possible solution "MikeD" <nobody@nowhere.edu> - 2011-05-22 17:01 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 18:28 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 18:29 -0400
Re: [OT] Bolding text. Dee Earley <dee.earley@icode.co.uk> - 2011-05-23 10:54 +0100
Re: [OT] Bolding text. "Jim Mack" <no-uce-ube@mdxi.com> - 2011-05-23 09:33 -0400
Re: [OT] Bolding text. Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2011-05-23 17:48 +0200
Re: [OT] Bolding text. Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2011-05-23 18:00 +0200
Re: [OT] Bolding text. Dee Earley <dee.earley@icode.co.uk> - 2011-05-24 10:44 +0100
Re: Need help with writing drive property: Possible solution "MikeD" <nobody@nowhere.edu> - 2011-05-23 08:51 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-23 10:48 -0400
Re: Need help with writing drive property: Possible solution "Mayayana" <mayayana@invalid.nospam> - 2011-05-22 09:23 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 14:36 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 14:49 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 16:26 -0400
Re: Need help with writing drive property: Possible solution "Mayayana" <mayayana@invalid.nospam> - 2011-05-22 18:29 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 18:33 -0400
Re: Need help with writing drive property: Possible solution "Mayayana" <mayayana@invalid.nospam> - 2011-05-22 18:36 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 18:49 -0400
Re: Need help with writing drive property: Possible solution "Mayayana" <mayayana@invalid.nospam> - 2011-05-22 20:48 -0400
Re: Need help with writing drive property: Possible solution GS <gs@somewhere.net> - 2011-05-22 21:30 -0400
Re: Need help with writing drive property "MikeD" <nobody@nowhere.edu> - 2011-05-21 19:42 -0400
Re: Need help with writing drive property GS <gs@somewhere.net> - 2011-05-21 20:14 -0400
Re: Need help with writing drive property - Final Approach GS <gs@somewhere.net> - 2011-05-23 13:20 -0400
csiph-web