DeviceIoControl

  • Thread starter Thread starter Lou
  • Start date Start date
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.
 
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
 
Lou said:
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.
 
Back
Top