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 2 3124
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.
"Jim Flanagan" <jf***@tampabay.rr.comwrote in message
news:nT*****************@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
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.
Terry -
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dim |
last post by:
Copied directly from exaple book but not working....
All i get is an empty 0 byte file
Call to GetLastError directly after the call to WriteFile returns 0
(NO_ERROR) but no data sees to be written...
|
by: Chuck Rittersdorf |
last post by:
Hi There
I am having a problem using the win32 API from VB6.
I am trying to send a command string to a printer(zebra TLP 2742) on
LPT1
using the folowing API functions
CreateFile and...
|
by: toshizo |
last post by:
Hi, I want to write MBR of a removal disk, compact flash card.
I use CreateFile() function to access the removal disk, but I can't get
valid disk handle because I don't have an administration...
|
by: Soundneedle |
last post by:
Does anyone have any code snips that retrieves a file's (txt, xl, etc)
created, accessed, and modified date properties? I've searched this
group and couldn't find anything simple....
TIA
|
by: Jason Dravet |
last post by:
Some time ago I wrote an application that controls the projectors in our
classrooms(turn on, turn off, and volume control). This application is
written in VB.net 2003. It was working perfectly...
| |
by: Terry Olsen |
last post by:
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...
|
by: Asfar |
last post by:
I have a MFC dll in which one of the parameters is of LPSTR.
The declaration of my MFC dll looks like
extern "C" __declspec(dllexport) int WINAPI EXPORT TestPInvokeFunc(LPSTR
szFileName, LPSTR...
|
by: Lou |
last post by:
i am using CreateFile in a VB6 app but it doesn't work in VB .NET COM dll.
hGpiFile = CreateFile("\\.\BLIO1", GENERIC_READ Or GENERIC_WRITE, 0,
gblSecurity, OPEN_EXISTING, 0, 0)
I get an error...
|
by: Ketchup |
last post by:
Hello everyone,
I have been stuck with this problem for quite some time now. I am working in VB.NET, using framework 1.0. I have to keep the compatibility down to the original .NET framework...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |