|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need help with CreateFile API functionI am using VB.net Express to experiment with the Win32 API functions that are available. The current project is an application that will read the raw sectors of a logical drive so that a CRC-32 calculation can be performed on all of the bytes of the logical drive. This is my first experience with the CreateFile function. Here is the problem(s) that I am having. Here is my declaration of the function in a separate module. Declare Function CreateFile Lib "kernel32" _ Alias "CreateFileA" ( _ ByVal lpFileName As String, _ ByVal dwDesiredAccess As Integer, _ ByVal dwShareMode As Integer, _ ByRef lpSecurityAttributes As Integer, _ ByVal dwCreationDisposition As Integer, _ ByVal dwFlagsAndAttributes As Integer, _ ByVal hTemplateFile As Integer) As Integer Here is how I am calling the function: Simply trying to open a file for reading... hDevice = CreateFile("C:\Autoexec.bat", GENERIC_READ, _ FILE_SHARE_READ Or FILE_SHARE_WRITE, _ 0%, _ OPEN_EXISTING, _ 0%, 0%) Initially, I was having success opening a physical drive using this function. However, all of a sudden I am now getting a system error: "The revision level is unknown." and the function fails. I'm stumped. If anyone has any suggestions would be appreciated. Thanks. -jim Here's a program I wrote that makes images of floppy disks, it uses the
CreateFile API. http://boycot.no-ip.com/vb/RawReadWriteFloppy.htm I used Int32 instead of Integer for types, not sure if that will make a difference or not, but I used IntPtr for lpSecurityAttributes. Show quoteHide quote "Jim Flanagan" <jf***@tampabay.rr.com> wrote in message news:nTnah.10688$CR6.487@tornado.tampabay.rr.com... > Hi... > I am using VB.net Express to experiment with the Win32 API functions that > are available. The current project is an application that will read the > raw sectors of a logical drive so that a CRC-32 calculation can be > performed on all of the bytes of the logical drive. This is my first > experience with the CreateFile function. > > Here is the problem(s) that I am having. > > > Here is my declaration of the function in a separate module. > Declare Function CreateFile Lib "kernel32" _ > Alias "CreateFileA" ( _ > ByVal lpFileName As String, _ > ByVal dwDesiredAccess As Integer, _ > ByVal dwShareMode As Integer, _ > ByRef lpSecurityAttributes As Integer, _ > ByVal dwCreationDisposition As Integer, _ > ByVal dwFlagsAndAttributes As Integer, _ > ByVal hTemplateFile As Integer) As Integer > > Here is how I am calling the function: > > Simply trying to open a file for reading... > > hDevice = CreateFile("C:\Autoexec.bat", GENERIC_READ, _ > FILE_SHARE_READ Or FILE_SHARE_WRITE, _ > 0%, _ > OPEN_EXISTING, _ > 0%, 0%) > > Initially, I was having success opening a physical drive using this > function. However, all of a sudden I am now getting a system error: > > "The revision level is unknown." > > and the function fails. > > > I'm stumped. If anyone has any suggestions would be appreciated. > Thanks. > -jim > Here's a program I wrote that makes images of floppy disks, it uses the Terry -> CreateFile API. http://boycot.no-ip.com/vb/RawReadWriteFloppy.htm > > I used Int32 instead of Integer for types, not sure if that will make a > difference or not, but I used IntPtr for lpSecurityAttributes. I just tried your method of declaring the CreateFile function and it appeared to resolve my problem. I *think* the problem was not the Int32 definition, but the IntPtr. Everything seems to work OK now. Thanks for sharing your code example. Take care -jim
what is a static property and a cursor question
Why is this simple addition throwing an overflow exception? Delete Directory not working Create Serial Number Data entry into ComboBox VS 2005 baffled at step 1 Problem saving txt box with enter key How to run and communicate a DOS program file in a VB.NET program? Add usercontrol to listbox 'System.Management.ManagementClass' is not defined |
|||||||||||||||||||||||