Read/write to sectors 
Author Message
 Read/write to sectors

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



Sun, 17 Jun 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. How do I Read/Write BOOT SECTOR in VB 4.0

2. read/write directly disk sectors.

3. Reading/Writing Sector Directly Under Windows 98/ME

4. Reading/Writing Sectors

5. How to read and write sectors to floppydisk

6. Writing And Reading to Track & Sector

7. Reading and writing disk sectors.

8. Writing to Boot Sector

9. ABF) Writing to a specific sector on a disk

10. Writing to floppy disk boot sector - how ?

11. Write to boot sector with VB?

12. Write to a defined Sector on the Floppy

 

 
Powered by phpBB® Forum Software