Solved

IOCTL  control code to use in DeviceIoControl

Posted on 2000-02-19
12
944 Views
Last Modified: 2007-10-18
I face a problem in finding a proper IOCTL control code to control my parallel port. I just wanna send output to data port. do i have to define the control codes on my own. if i have to, but how to write it?
thanks.
0
Comment
Question by:giggs11
  • 6
  • 5
12 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2538010
Why do you want to use IOCTL?  You can open the port as a file with CreateFile() and send the data with WriteFile().   You can control communications using the communication functions, like (SetCommMask(), SetCommTimeouts(), SetCommModemStatus() etc.)
0
 
LVL 3

Expert Comment

by:ufolk123
ID: 2539279
0
 

Author Comment

by:giggs11
ID: 2539734
is it workable in the NT?
0
 
LVL 22

Expert Comment

by:nietod
ID: 2539749
Is what workable?  The functions I mentioned?  Of course, they are part of the windows API.
0
 

Author Comment

by:giggs11
ID: 2548645
what's the parameter 4 in WriteFile()? what should i insert as i'm going to send 1 byte of data from nPtr. Is it sth wrong with WriteFile(hDevice,nptr,1,1,NULL). pls advice
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 2548673
It is a pointer to a DWORD value.  The function will set this DWROD value to the number of bytes it writes.  If everything goes okay this should be the number you specified in parameter 3.  but if there is an error, this might be less (like 0, or any number less than the amount you specified.)

DWORD BytWrt;

WriteFile(hDevice,nptr,1,&BytWrt,NULL)

if (BytWrt != 1)
  there was some sort of error.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:giggs11
ID: 2551480
i'm sending data to parallel port. by WriteFile how do i send data to data port (0x378) and control port (0x37a)
0
 
LVL 22

Expert Comment

by:nietod
ID: 2551788
WriteFile() writes data to the specified port.  You don't deal with I/O addresses this way.  you can't access the i/O ports directly from a user application in win32.  You have to use the API functions, like WriteFile() or you have to use a device driver.

There are numerous functions for controlling communications, see the functions I originally suggested.  They will lead you to other functions that may be of value too.
0
 

Author Comment

by:giggs11
ID: 2556845
i have tried to sent output to my parallel port, but there're some clash between the printer i set on the same port (LPT1) before. the message is the printer is not ready. i deleted the printer driver on the LPT1 but there seem no LPT1 in NT right now. there're lots of different with win98 which NT is quite new for me. is that the function you suggested before can solve the problem. thanks.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2557947
I beleive, you must have a driver for this port, so when you delete the printer you deleted the driver windows uses to write to the port.

I would try installing a printer for that port.
0
 

Author Comment

by:giggs11
ID: 2560279
i have read through the function you have suggested, but it seem that there are no way in sending and receive data in data, status and control port like what can be done in Win98. is that any other route?
by the way, where should get more info to use the function you have suggested beside help in VC, like example or what. thanks.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2560902
You cannot directly access the I/O ports.  But you shouldn't need to.  There are communication functions that will set up the communication proticall so you don't have to access the port.  Like to set baud rate, RTS/CTS, XON/XOFF that sort of thing.  Why do you need to access the ports, what do you wish to do?

>> where should get more info to use the
>> function you have suggested beside help in VC,
Nowhere I can think of.

What in particular are you trying to do?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Template syntax for variable length arrays 9 71
SNMP error No Such Object available on this agent at this OID 3 182
Unable to start eclipse ? 17 128
Issues with C++ Class 19 78
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now