This little procedure (sorry it's vb but that's not the point) writes/reads
sectors on a floppy disk. This procedure does worke ok with win95/98. But it
needs the file VWIN32.vxd which doesn't exist under WinNT.
How I can do this job unter NT? how can I read/write to sectors with the API
Function DeviceIoControl(...) ?
Greetings Patrick
'=== Konstanten ===
Private Const VWIN32_DIOC_DOS_INT25 = 2 ' Lesen
Private Const VWIN32_DIOC_DOS_INT26 = 3 ' Schreiben
'=== Types ===
Private Type DIOCRegs
ebx As String
edx As Long
ecx As Long
eax As Long
edi As Long
esi As Long
flags As Long
End Type
'=== Declares ===
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
(ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal
dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal
dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal
hTemplateFile As Long) As Long
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As
Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize
As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned
As Long, ByVal lpOverlapped As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)
As Long
'=== Funktionen ===
Public Function LeseSektor(Lesen As Integer) As Boolean
Dim Handle As Long
Dim Ergebnis As Boolean
Dim BytesReturned As Long
Dim Regs As DIOCRegs
'Win95/98
Handle = CreateFile("\\.\vwin32", 0, 0, 0, 0, 0, 0)
Regs.eax = &H0
Regs.ecx = &H1
Regs.edx = &H0
Regs.ebx = Space(512)
If Lesen = 1 Then
Ergebnis = DeviceIoControl(Handle, VWIN32_DIOC_DOS_INT25, _
Regs, Len(Regs), _
Regs, Len(Regs), _
BytesReturned, 0)
Wunsch$ = Regs.ebx
Else
Regs.ebx = "blabla"
Ergebnis = DeviceIoControl(Handle, VWIN32_DIOC_DOS_INT26, _
Regs, Len(Regs), _
Regs, Len(Regs), _
BytesReturned, 0)
End If
CloseHandle Handle
End Function