Search code examples
windows-7dparallel-port

D accessing parallel port under windows


I can simply access parallel port with D in Ubuntu like this.

import std.stdio;
import core.bitop;

// parallel port address 
const uint port = 0x0c000;

void main()
{
    /*
        permission related stuff under linux
    */

    /* data */
    ubyte data = 0b_11111111;
    outp(port, data);
}

But I would like to read and write to a parallel port on windows. When I try this code I get this error message.

object.Error: Privileged Instruction
----------------
41377C
4135F3
4025BC
4021B3
4BD6F9
1553C6
----------------

Is there a simple way to access parallel port on windows using D? Thanks..


Solution

  • Windows does not grant user-mode programs direct hardware access. You will need to write a driver (.sys file), most likely in C (using the WINDDK). You will also need to purchase a code-signing certificate to allow your driver to run on 64-bit Windows versions (or disable driver signing, if you only need to run it on your machine).