Groups | Blog | Home
all groups > vb.net > september 2007 >

vb.net : DeviceIoControl


Lou
9/28/2007 7:24:32 PM
is there a VB .NET way to use the API "DeviceIoControl"?
-Lou

Herfried K. Wagner [MVP]
9/29/2007 1:39:38 AM
"Lou" <lou.garvin@comcast.net> schrieb:
[quoted text, click to view]

Yes. What exactly are you looking for?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
Lou
10/2/2007 11:50:26 AM
I need to communicate to a Blastronics Serial and GPI board.

[quoted text, click to view]

Dick Grier
10/2/2007 12:38:23 PM
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.

Lou
10/2/2007 3:34:02 PM
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::DeviceIoControl' 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

[quoted text, click to view]

Herfried K. Wagner [MVP]
10/2/2007 11:05:55 PM
"Lou" <lou.garvin@comcast.net> schrieb:
[quoted text, click to view]

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/>
AddThis Social Bookmark Button