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 "CreateFile A" ( _
ByVal lpFileName As String, _
ByVal dwDesiredAccess As Integer, _
ByVal dwShareMode As Integer, _
ByRef lpSecurityAttri butes As Integer, _
ByVal dwCreationDispo sition As Integer, _
ByVal dwFlagsAndAttri butes 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_WRIT E, _
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 3139
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 lpSecurityAttri butes.
"Jim Flanagan" <jf***@tampabay .rr.comwrote in message
news:nT******** *********@torna do.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 "CreateFile A" ( _
ByVal lpFileName As String, _
ByVal dwDesiredAccess As Integer, _
ByVal dwShareMode As Integer, _
ByRef lpSecurityAttri butes As Integer, _
ByVal dwCreationDispo sition As Integer, _
ByVal dwFlagsAndAttri butes 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_WRIT E, _
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 lpSecurityAttri butes.
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 :-(
??????????
Thx
|
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 WriteFile
I have written C code which works fine, just the VB translation/port
|
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 privilege in Windows
XP.
Can't I use CreateFile() function without administrator privilege?
Do you know any other ways?
Please give me your ideas.
Best Regards,
toshizo
|
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 until XP SP2 was installed
on the PCs. Now when the power on or power off button is pressed the
following message is displayed:
An unhandled exception has occurred in your application. If you click
Continue, the application will ignore this...
| |
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 (returning a -1).
Here's the code:
Const GENERIC_READ = &H80000000
Const OPEN_EXISTING = 3
Const FILE_SHARE_READ = &H1
Const FILE_SHARE_WRITE = &H2
Const FILE_ATTRIBUTE_NORMAL = &H80
|
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 szResult)
{
char resultchar;
//some processing which put the result values in resultchar
strcpy(szResult, &resultchar);
return 0;
|
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 message:
A call to PInvoke function 'BlastronicsGpi!BlastronicsGpi.cGpi::CreateFile'
has unbalanced the stack. This is likely because the managed PInvoke
signature does not match the unmanaged target signature. Check that the
calling convention...
|
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 as much as possible. I am forced to use API calls for several functions, one of which is ReadFile. The reason is because the framework seems to use ANSI versions of all API functions, limiting the MAX_PATH for filenames to about 260 chars for ...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 we have to send another system
| |