The NTFS information includes such things as the drive's NTFS version number, number of sectors, number of free sectors, and so forth.
The program uses the ExecAndCapture function to execute the following command line and capture its output.
fsutil fsinfo ntfsinfo c:
It displays the information returned in the txtResults text box.
|
Public Function ExecAndCapture(ByVal cmd As String, _
Optional ByVal start_dir As String = vbNullString) As _
String
Const BUFSIZE As Long = 1024 * 10
Dim hPipeRead As Long
Dim hPipeWrite As Long
Dim sa As SECURITY_ATTRIBUTES
Dim si As STARTUPINFO
Dim pi As PROCESS_INFORMATION
Dim baOutput(BUFSIZE) As Byte
Dim result As String
Dim lBytesRead As Long
With sa
.nLength = Len(sa)
.bInheritHandle = 1 ' get inheritable pipe
' handles
End With 'SA
If CreatePipe(hPipeRead, hPipeWrite, sa, 0) = 0 Then
ExecAndCapture = "Error creating pipe"
Exit Function
End If
With si
.cb = Len(si)
.dwFlags = STARTF_USESHOWWINDOW Or _
STARTF_USESTDHANDLES
.wShowWindow = SW_HIDE ' hide the window
.hStdOutput = hPipeWrite
.hStdError = hPipeWrite
End With 'SI
If CreateProcess(vbNullString, cmd, ByVal 0&, ByVal 0&, _
1, 0&, ByVal 0&, start_dir, si, pi) Then
CloseHandle hPipeWrite
CloseHandle pi.hThread
hPipeWrite = 0
Do
DoEvents
If ReadFile(hPipeRead, baOutput(0), BUFSIZE, _
lBytesRead, ByVal 0&) = 0 Then
Exit Do
End If
result = Left$(StrConv(baOutput(), vbUnicode), _
lBytesRead)
Loop
CloseHandle pi.hProcess
Else
result = "Error creating process"
End If
' To make sure...
CloseHandle hPipeRead
CloseHandle hPipeWrite
ExecAndCapture = result
End Function
|