Accessing to I/Os (Serial, Parallel, USB, etc)

M

MSDousti

Hi, everyone.

I have written this code in Tubo C++ 3.0 earlier, and now I want to
port it to VC.NET:

int out=0;
out=(out & 0xDF);
outportb(0x378,out);
....
As you see, it seeks to parallel port directly (port: 0x378)

How can I write this code in VC++ .NET?
 
C

Carl Daniel [VC++ MVP]

MSDousti said:
Hi, everyone.

I have written this code in Tubo C++ 3.0 earlier, and now I want to
port it to VC.NET:

int out=0;
out=(out & 0xDF);
outportb(0x378,out);
....
As you see, it seeks to parallel port directly (port: 0x378)

How can I write this code in VC++ .NET?

The problem is not VC++ or .NET, but Windows itself. Modern operating
systems - Windows NT/2000/XP/Linux/Unix/etc do not allow direct access to
hardware I/O ports from application programs. Rather, access to
hardware-level I/O is restricted to the OS kernel, and the device drivers
that support it.

In order to access hardware directly, you need to write (or use) a kernel
device driver.

What exactly are your trying to do? There may already be a way to
accomplish what you need with an existing high-level API.

-cd
 
A

ahmed fat-hi

search for winio.dll on net , it will help u to access
parallel port.

the syntax u wrote will run only on windows 98 and lower
 
M

MSDousti

Carl Daniel said:
The problem is not VC++ or .NET, but Windows itself. Modern operating
systems - Windows NT/2000/XP/Linux/Unix/etc do not allow direct access to
hardware I/O ports from application programs. Rather, access to
hardware-level I/O is restricted to the OS kernel, and the device drivers
that support it.

In order to access hardware directly, you need to write (or use) a kernel
device driver.

What exactly are your trying to do? There may already be a way to
accomplish what you need with an existing high-level API.

-cd

I'm sure you know we can access a port through CreateFile(...)
function. Just I should set a handle to the approprite port, e.g
"COM1" or "LPT1".

I exactly want to know what other handles there are, e.g. for USB,
etc.
 
W

William DePalo [MVP VC++ ]

MSDousti said:
I'm sure you know we can access a port through CreateFile(...)
function. Just I should set a handle to the approprite port, e.g
"COM1" or "LPT1".

Yes, that's true. Applications access devices through the intervention of
the operating system and its drivers which interacts with the hardware.
That's the point that Carl made.
I exactly want to know what other handles there are, e.g. for USB,
etc.

As I see it, your question is a bit open-ended as there are many kinds of
devices that plug into the USB bus. You might want to post again, possibly
with more detail as to what you want to do, in

microsoft.public.win32.programmer.kernel

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top