Link to home
Start Free TrialLog in
Avatar of giggs11
giggs11

asked on

IOCTL control code to use in DeviceIoControl

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.
Avatar of nietod
nietod

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.)
Avatar of giggs11

ASKER

is it workable in the NT?
Is what workable?  The functions I mentioned?  Of course, they are part of the windows API.
Avatar of giggs11

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of giggs11

ASKER

i'm sending data to parallel port. by WriteFile how do i send data to data port (0x378) and control port (0x37a)
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.
Avatar of giggs11

ASKER

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.
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.
Avatar of giggs11

ASKER

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.
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?