bogdandaniel
Member
- Joined
- Mar 28, 2003
- Messages
- 11
What is wrong with tis code? The result is always false:
Code:
Private Const DFP_GET_VERSION As Integer = &H74080
Private Const GENERIC_READ As Integer = &H80000000
Private Const GENERIC_WRITE As Integer = &H40000000
Private Const FILE_SHARE_READ As Short = &H1S
Private Const FILE_SHARE_WRITE As Short = &H2S
Private Const OPEN_EXISTING As Short = 3
Private Const FILE_ATTRIBUTE_SYSTEM As Short = &H4S
Private Const CREATE_NEW As Short = 1
Private Const IOCTL_STORAGE_CHECK_VERIFY2 As Integer = &H2D0800
Private Const FILE_READ_ATTRIBUTES As Integer = &H80
Private Const IOCTL_DISK_GET_DRIVE_GEOMETRY As Integer = &H70000
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Integer, ByVal dwIoControlCode As Integer, ByRef lpInBuffer As IntPtr, ByVal nInBufferSize As Integer, ByRef lpOutBuffer As GETVERSIONOUTPARAMS, ByVal nOutBufferSize As Integer, ByRef lpBytesReturned As Integer, ByVal lpOverlapped As IntPtr) As Integer
Structure GETVERSIONOUTPARAMS
Dim bVersion As Byte Binary driver version.
Dim bRevision As Byte Binary driver revision.
Dim bReserved As Byte Not used.
Dim bIDEDeviceMap As Byte Bit map of IDE devices.
Dim fCapabilities As Integer Bit mask of driver capabilities.
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> _
Dim dwReserved() As Integer
End Structure
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
Dim hdrive As Integer
Dim VersionParams As New GETVERSIONOUTPARAMS()
hdrive = CreateFile("\\.\PHYSICALDRIVE0", 0, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero)
Dim bytesReturned As Integer
Dim result As Boolean
result = DeviceIoControl(hdrive, DFP_GET_VERSION, IntPtr.Zero, 0, VersionParams, 24, bytesReturned, IntPtr.Zero)
CloseHandle(hdrive)
MsgBox(result)
End Sub