Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2007

Tip: Looking for answers? Try searching our database.

DeviceIoControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lou - 29 Sep 2007 00:24 GMT
is there a VB .NET way to use the API  "DeviceIoControl"?
-Lou
Herfried K. Wagner [MVP] - 29 Sep 2007 00:39 GMT
"Lou" <lou.garvin@comcast.net> schrieb:
> is there a VB .NET way to use the API  "DeviceIoControl"?

Yes.  What exactly are you looking for?

Signature

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

Lou - 02 Oct 2007 16:50 GMT
I need to communicate to a Blastronics Serial and GPI board.

> "Lou" <lou.garvin@comcast.net> schrieb:
>> is there a VB .NET way to use the API  "DeviceIoControl"?
>
> Yes.  What exactly are you looking for?
Dick Grier - 02 Oct 2007 19:38 GMT
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

Signature

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 - 02 Oct 2007 20:34 GMT
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

> Jeffrey Rickter wrote an article on DeviceIOControl for MSDN Magazine
> (January 2007).  This sould be available online, and it may answer your
[quoted text clipped - 6 lines]
>
> Dick
Herfried K. Wagner [MVP] - 02 Oct 2007 22:05 GMT
"Lou" <lou.garvin@comcast.net> schrieb:
> the serial ports work fine, its the 25 pin GPI ports that work great in
> VB6 using 2 API calls
[quoted text clipped - 3 lines]
> 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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.