Turbo/c程式PRINTER PORT視窗DOS的問題

我在自習一種.微電腦介面控制實習並列埠

買了一本微電腦介面控制實習的書來練

但是發現程式只能在DOS下執行的時候動

作都正常.可是在視窗軟體下沒有動作.想知道

這程式要怎麼修改才能在視窗軟體下執行.

我用的是windows 7

有前輩說可能是Outportb的問題但我不知要怎改

才能在windows 7下正常動作

以下是堤共的程式碼Turbo c2.0

#include <stdio.h>

#include <dos.h>

#define print_port 0x378

unsigned char led_tab[]={0x01,0x02,0x04,0x08,

0x10,0x20,0x40,0x80,0x80,0x40,0x20,0x10,0x08,

0x04,0x02,0x01};

main()

{ char i ;

Outportb(print_port+2,0);

While(1)

{

for(i=0;i<16;i++)

{

Outportb(print_port,led_tab[i]);

Delay(25000) ;

}

}

}

8 Answers

Rating
  • Chen
    Lv 6
    6 years ago
    Favorite Answer

    The reason why Your program couldn't run in windows 7, I had mentioned before.

    I suggest that You should use open device name, then write and ioctl it in user mode.

    parallel port device driver is partport.sys in \windows\system32\driver

    It can create device name in \device\parallport0 like picture

    and You check if It can symboliclink \Dosdevices\LPT1. if yes , You can open "LPT1", or \device\parallport0

    picture1

    圖片參考:https://s.yimg.com/rk/AC08187637/o/2101954807.jpg

    2014-05-17 10:33:30 補充:

    to modify device name, \device\ paralledport0

    2014-05-17 10:55:56 補充:

    this device supports IRP_MJ_Create, write, read, device_control, query_information ...etc

    • Commenter avatarLogin to reply the answers
  • 6 years ago

    到下面的網址看看吧

    ▶▶http://candy5660601.pixnet.net/blog

    • Commenter avatarLogin to reply the answers
  • Anonymous
    6 years ago

    到下面的網址看看吧

    ▶▶http://candy5660601.pixnet.net/blog

    • Commenter avatarLogin to reply the answers
  • 6 years ago

    參考下面的網址看看

    http://phi008780520.pixnet.net/blog

    • Commenter avatarLogin to reply the answers
  • How do you think about the answers? You can sign in to vote the answer.
  • Anonymous
    6 years ago

    參考下面的網址看看

    http://phi008780520.pixnet.net/blog

    • Commenter avatarLogin to reply the answers
  • 6 years ago

    參考下面的網址看看

    http://phi008780520.pixnet.net/blog

    • Commenter avatarLogin to reply the answers
  • 6 years ago

    你好~咕咕吉工作室很高興為您回答

    若你想在win7下RUN TURBO C的程式是可以做的到的,你去下載一個叫DOSBOX的DOS模擬器,安裝好它後,你打開這程式這是彷DOS系統的程式,你在將你TURBO C產生的EXE檔放到C曹底下,並下指令開起它,另外你的378 PORT 你並列出來接LED顯示看看就知道你送的資料對不對了

    買電子零件請到 www.chiptw.com

    • Commenter avatarLogin to reply the answers
  • 卸貨
    Lv 5
    6 years ago
    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.