I'm trying to create a disk image of a floppy disk. Since I can't open
the device using the system.io methods, i'm trying to use the CreateFile
API to get a handle for me. But the call fails (returning a -1).
Here's the code:
Const GENERIC_READ = &H80000000
Const OPEN_EXISTING = 3
Const FILE_SHARE_READ = &H1
Const FILE_SHARE_WRIT E = &H2
Const FILE_ATTRIBUTE_ NORMAL = &H80
Const FILE_FLAG_NO_BU FFERING = &H20000000
Declare Function CreateFile Lib "kernel32"
Alias "CreateFile A" (ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByVal lpSecurityAttri butes As Long, _
ByVal dwCreationDistr ibution As Long, _
ByVal dwFlagsAndAttri butes As Long, _
ByVal hTemplateFile As Long) As IntPtr
Dim fh As IntPtr = CreateFile("\\. \A:", _
GENERIC_READ, _
FILE_SHARE_READ Or FILE_SHARE_WRIT E, _
0, _
OPEN_EXISTING, _
FILE_ATTRIBUTE_ NORMAL Or FILE_FLAG_NO_BU FFERING, _
0)
I'm hoping someone can tell me what's wrong here and help me fix it so I
get a valid handle returned.
*** Sent via Developersdex http://www.developersdex.com ***
the device using the system.io methods, i'm trying to use the CreateFile
API to get a handle for me. But the call fails (returning a -1).
Here's the code:
Const GENERIC_READ = &H80000000
Const OPEN_EXISTING = 3
Const FILE_SHARE_READ = &H1
Const FILE_SHARE_WRIT E = &H2
Const FILE_ATTRIBUTE_ NORMAL = &H80
Const FILE_FLAG_NO_BU FFERING = &H20000000
Declare Function CreateFile Lib "kernel32"
Alias "CreateFile A" (ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByVal lpSecurityAttri butes As Long, _
ByVal dwCreationDistr ibution As Long, _
ByVal dwFlagsAndAttri butes As Long, _
ByVal hTemplateFile As Long) As IntPtr
Dim fh As IntPtr = CreateFile("\\. \A:", _
GENERIC_READ, _
FILE_SHARE_READ Or FILE_SHARE_WRIT E, _
0, _
OPEN_EXISTING, _
FILE_ATTRIBUTE_ NORMAL Or FILE_FLAG_NO_BU FFERING, _
0)
I'm hoping someone can tell me what's wrong here and help me fix it so I
get a valid handle returned.
*** Sent via Developersdex http://www.developersdex.com ***
Comment