473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DeviceIoControl

Lou
is there a VB .NET way to use the API "DeviceIoControl"?
-Lou
Sep 28 '07 #1
5 3790
"Lou" <lo********@comcast.netschrieb:
is there a VB .NET way to use the API "DeviceIoControl"?
Yes. What exactly are you looking for?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Sep 28 '07 #2
Lou
I need to communicate to a Blastronics Serial and GPI board.

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:ec**************@TK2MSFTNGP03.phx.gbl...
"Lou" <lo********@comcast.netschrieb:
>is there a VB .NET way to use the API "DeviceIoControl"?

Yes. What exactly are you looking for?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Oct 2 '07 #3
Jeffrey Rickter wrote an article on DeviceIOControl for MSDN Magazine
(January 2007). This sould be available online, and it may answer your
questions.

I'm not familiar with your board, but my guess is that the serial portion is
standard and System.IO.Port.SerialPort will do what you need. I also
provide a .NET control called IONET that allows you to read and write
conventional IO ports.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Oct 2 '07 #4
Lou
Thanks Dick, glad to hear from you again.
the serial ports work fine, its the 25 pin GPI ports that work great in VB6
using 2 API calls
CreateFile and DeviceIoControl.
Like I said they work fine in VB6 but the code fails in .NET

CreateFile gives me the error:
PInvokeStackImbalance was detected
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 and parameters
of the PInvoke signature match the target unmanaged signature.

but does give me a handle.

DeviceIoControl gives me the error:
PInvokeStackImbalance was detected
Message: A call to PInvoke function
'BlastronicsGpi!BlastronicsGpi.cGpi::DeviceIoContr ol' has unbalanced the
stack. This is likely because the managed PInvoke signature does not match
the unmanaged target signature. Check that the calling convention and
parameters of the PInvoke signature match the target unmanaged signature.

And does not get back the bytes..

Wierd!
VB6 great product!

-Lou

"Dick Grier" <dick_grierNOSPAM@.msn.comwrote in message
news:eK**************@TK2MSFTNGP05.phx.gbl...
Jeffrey Rickter wrote an article on DeviceIOControl for MSDN Magazine
(January 2007). This sould be available online, and it may answer your
questions.

I'm not familiar with your board, but my guess is that the serial portion
is standard and System.IO.Port.SerialPort will do what you need. I also
provide a .NET control called IONET that allows you to read and write
conventional IO ports.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.

Oct 2 '07 #5
"Lou" <lo********@comcast.netschrieb:
the serial ports work fine, its the 25 pin GPI ports that work great in
VB6 using 2 API calls
CreateFile and DeviceIoControl.
Like I said they work fine in VB6 but the code fails in .NET

CreateFile gives me the error:
PInvokeStackImbalance was detected
VB6 and VB.NET use different types, thus it's not possible to transfer
declarations and code from VB6 to VB.NET without manual revision. Most
likely your declarations for 'CreateFile' and 'DeviceIoControl' are wrong.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Oct 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ewoo | last post by:
I'm trying to write a wrapper in csharp to wrap DeviceIoControl() win32 method for IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS control code--without much luck. I've seen lots of examples out there for...
2
by: Ken Allen | last post by:
I am looking for information on using the Win32 API procedure, or its equivalent in C#. I have looked but can find no satisfactory references. I am working on an existing product that has a few...
2
by: Michael Allen | last post by:
I would like to perform something similar to the below function in C# .NET. The C++ below code is from a Microsoft DDK sample driver application. Specifically, I would like to perform Device I/O...
3
by: Jacky | last post by:
Hi, I am trying to make network card interface with VB.NET 2002. I use DeviceIOControl-function. I have tried to define inbuffer and outbuffer using byte array and it's pointer. The second I...
1
by: Pixie | last post by:
I am trying to query the change journal using the deviceIOControl API. The API doesn't return an error, but all of the values in the output buffer are zero, and they shouldn't be. My code is below. I...
0
by: Pixie | last post by:
We are successfully getting a handle to a drive using createfile then using that handle to query the change journal using DeviceIOControl with the paramter FSCTL_QUERY_USN_DATA. However when we try...
1
by: Juan Pedro Gonzalez | last post by:
Helo, I'm having problems here with the input buffer.... Ive defined the API call as: <System.Runtime.InteropServices.DllImport("kernel32", SetLastError:=True)> _ Private Shared Function...
0
by: Andrew | last post by:
Hello I am trying to port some code and I am running into some issues I may or may not be able to solve on my own and would appreciate your help Basically I am trying to open the Tun Driver...
4
by: =?Utf-8?B?TWFyaW5h?= | last post by:
Does any know any sample of how to do a basic DeviceIoControl with something like IOCTL_BATTERY_GETSYSTEMPOWERSTATUSEX2 in C# I have been stuck all week :( and google doesnt yield anything of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.