"Rick Rothstein (MVP - VB)" wrote in message
Here is another way based on a posting by Larry Serflaten over in the
compiled VB newsgroups...
Public Sub GetDriveInfo(DriveLetter As String, HardDrive As HardDriveInfo)
Dim WMI, SYS, DRV
Set WMI = GetObject("winmgmts:\\.\root\CIMV2")
Set SYS = WMI.ExecQuery("SELECT * FROM Win32_LogicalDisk", "WQL", 48)
For Each DRV In SYS
<snip>
Hi Rick,
Another interesting solution. Unfortunately it doesn't work on my W98SE,
though it does in Vista.
Set WMI = GetObject("winmgmts:\\.\root\CIMV2")
err.432
File or classname not found during automation operation
Other things I've tried with "winmgmts" also fail in w9x, including yet
another approach sent to me by RBS off-line. Slightly different error -
Object doesn't support this property or method
By contrast, Randy Birch's code (the RBS link up top) works in W98 but fails
in Vista, I suspect 'cos of this-
Private Function SmartOpen(drvNumber As IDE_DRIVE_NUMBER) As Long
'Open SMART to allow DeviceIoControl
'communications and return SMART handle
If IsWinNT4Plus() Then
SmartOpen = CreateFile("\\.\PhysicalDrive" & CStr(drvNumber), _
GENERIC_READ Or GENERIC_WRITE, _
FILE_SHARE_READ Or FILE_SHARE_WRITE, _
ByVal 0&, _
OPEN_EXISTING, _
0&, _
0&)
Else
SmartOpen = CreateFile("\\.\SMARTVSD", _
0&, 0&, _
ByVal 0&, _
CREATE_NEW, _
0&, _
0&)
End If
End Function
I hope Randy Birch does not mind my posting this function (see link above),
though I've seen virtually the same function in a number of sources. Anyway,
in my Vista SmartOpen returns -1 which in effect is non-valid. FWIW
IsWinNT4Plus returns true but SmartOpen returns -1 with both true/false
variations.
Unless I can get GetObject("winmgmts: etc working for all W98 users, or the
SmartOpen function working for all Vista users, seems I would need radically
different solutions to cater for different OS. Unless of course you have any
more ideas
Regards,
Peter T