By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,314 Members | 1,793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,314 IT Pros & Developers. It's quick & easy.

DeviceIoControl

P: n/a
Lou
is there a VB .NET way to use the API "DeviceIoControl"?
-Lou
Sep 28 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.