注册 登录
编程论坛 嵌入式开发

求助:WinIo的SetPortVal函数调用失败问题

可爱的大海 发布于 2019-03-08 16:49, 2866 次点击
在VC6.0中,使用WinIO向并口发送数据,SetPortVal函数调用失败。并口是PCI转并口卡,地址为3FF8.
#include <windows.h>
#include <stdio.h>
#include "WinIo.h"

void main()
{
   
  DWORD dwPortVal=0x0;
  bool bResult = InitializeWinIo();
  WORD m_port=(WORD)0x3FF8;
  // Call InitializeWinIo to initialize the WinIo library.
  while(true)
  {

      
      if (bResult)
      {
        // Under Windows NT/2000/XP, after calling InitializeWinIo,
        // you can call _inp/_outp instead of using GetPortVal/SetPortVal
        bool bSet =    SetPortVal(m_port,1,1);
        if(!bSet)
            printf("失败!\n");
        break;
        GetPortVal(m_port, &dwPortVal, 1);
        printf("端口值:%d\n",dwPortVal);
        Sleep(500);

        bResult=false;
    //    printf("success run WinIo.\n");

        // When you're done using WinIo, call ShutdownWinIo
      }
      if(!bResult)
      {
        // Under Windows NT/2000/XP, after calling InitializeWinIo,
        // you can call _inp/_outp instead of using GetPortVal/SetPortVal
        bool bSet =    SetPortVal(m_port,0,1);
        GetPortVal(m_port, &dwPortVal, 1);
        printf("端口值:%d\n",dwPortVal);
        Sleep(500);

        bResult=true;
    //    printf("success run WinIo.\n");

        // When you're done using WinIo, call ShutdownWinIo
      }
        
  }
  
ShutdownWinIo();

}
运行结果是显示失败,说明SetPortVal函数调用失败。请问原因出在哪?
0 回复
1