MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

APIs in the Kernel32.dll for Port I/O

  Asked By: Ted    Date: Dec 24    Category: MS Office    Views: 2124

I have the serial I/O going gang busters. I have this thought that
I could use the parallel port for some interesting stuff as well.
So, I...er...um... actually Google found that support.microsoft.com
has this section called:

HOW TO: Access Serial Ports and Parallel Ports by Using Microsoft
Visual Basic .NET

Now, I'm using these same kernel32 calls for my serial
I/O...HOWEVER in that section:


About 1/3 of the way down in the section:
Retrieve and Modify the Control Settings, in the second block of code
for "To reconfigure LPT1, use the following code:"

There appears to be a Cut and Paste error 'cuz it describes the
serial parameters again, for LPT1 !! Any way to get this correct.
I ... er...um, I mean Google couldn't find other explanations on
these API calls.



3 Answers Found

Answer #1    Answered By: Luete Fischer     Answered On: Dec 24

I checked it out. Have you tested it yet? I read through it and I don't
see any reason why it shouldn't work. 8N1 9600 are valid parameters  for
parallel as well as serial  ports I think. So I wouldn't assume this code
doesn't work.

And you'll notice the handles are appropriate in the two spots -
hParallelPort instead of hSerialPort, and you can see above where these
file handles get opened - hParallelPort = CreateFile(...)

So I would say, pretend it works and see if you can get it, and report
back if you do have a problem.

And congrats - directly programming the I/O is quite an accomplishment!

Answer #2    Answered By: Bodhi Smith     Answered On: Dec 24

Yea, I saw the handles, but they're just variable assignments...could
be anything typed/Pasted in...still could be a Cut/Paste error  as
in "Oops, got the handle, but forgot to change the other DCB
parameters after the paste." I did the comment thing at the bottom
of the support.mSoft page & will see...
Wow do you figure ("I think") those params are "valid" for 8-bit
parallel where there is a strobe and different control  lines?
Ignored, I could believe, just to satisfy the function call parameter
list requirement. The DCB example shows no parallel port  specific
params. This could be construed to mean that they have a
software "bit-banger" (as we used to call a software UART), but this
highly unlikely-- which pins are what?. I just find  it interesting
that there is always reference to serial  stuff in MSDN, but this was
the only parallel  reference I found  that wasn't printing specific and
way over my head (not that this wasn't two weeks ago).

I did find the Platform SDK stuff, on the MSDN site, which
appears to contain all the API calls, but don't want buy for my
meager need nor download the whole API doc just for this one (and
related) call(s)... Just a listing of the API calls  in the Kernel32
would be nice, though. I did "read" Kernel32 with Word, but the
format of the strings uses delimiters that can't be pasted into
Word's replace box (something Mac's Word always allowed) so I
couldn't atleast re-format and read the call names. There all jammed
together. There also appears to be a tool to read dlls to see what
calls are in them. The documentation should be easier, though. This
is getting too intense for me anyway. I was hoping (and still am)
that I can do it. I want to use this platform to do some up-front
work interfacing with a speech chip on the parallel port for some
blind specific SW.

Try-n-see-what-happens is an (all too common) option always, but can
be very expensive in time spent trying, trying, trying...
...which is what I do anyway...
Then, how to set the parallel port control lines if I need some...

You know...
We learn by our mistakes...

Answer #3    Answered By: Charlotte Brown     Answered On: Dec 24

The one on bbs.visualbasicforum talks about a direct IN & OUT
function in C(yuk). Is there anything like this in VBA? Memory
address accesses, aka Peek/Poke. I know how to do output in ASM to a
PC parallel port  - teach a class in basic  uP for Technicians and have
students do a "laser show"(simple image output) to one of my laser
projectors in class.

Didn't find what you were looking for? Find more on APIs in the Kernel32.dll for Port I/O Or get search suggestion and latest updates.