[問題] 如何控制virtual printer port I/O?
開發平台(Platform): VC++, BCB
額外使用到的函數庫(Library Used): WinIO
問題(Question):
小弟我使用了兩條USB to Parallel Cable(DB25 virtual printer port)
想使用WinIO去driver他的IO,但發現這個USB轉DB25的東西,好像不能用舊有的方法
直接去看他的Address,然後輸出。
因此想請問各位高手,能否提點小的一下?
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼:
#include "winio.h"
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
InitializeWinIo();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
ShutdownWinIo();
}
//---------------------------------------------------------------------------
unsigned long atoh(char*str)
{
unsigned long ulValue = 0L;
for(int i = 0;i<8;i++) //size of unsigned long is 8
{
if(str[i]==0)break; //string over
if((str[i]>=0x30)&&(str[i]<=0x39)){ //number
ulValue = ulValue*16+str[i]-0x30;
}else if((str[i]>=0x41)&&(str[i]<=0x46)){ //Upper letter
ulValue = ulValue*16+str[i]-0x37;
}else if((str[i]>=0x61)&&(str[i]<=0x66)){ //lower letter
ulValue = ulValue*16+str[i]-0x57;
}else{
ulValue = 0L;
break;
}
}
return ulValue;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
DWORD dwPortVal=0;
AnsiString tmp;
GetPortVal(atoh((Edit1->Text).c_str()), &dwPortVal, 4);
tmp.sprintf("%08x", dwPortVal);
Edit2->Text = tmp; //IntToHex((__int64)dwPortVal,1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
SetPortVal(atoh((Edit1->Text).c_str()), atoh((Edit2->Text).c_str()), 4);
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.200.8.199
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1420622828.A.2CC.html
推
01/07 17:30, , 1F
01/07 17:30, 1F
→
01/07 17:31, , 2F
01/07 17:31, 2F
→
01/07 17:32, , 3F
01/07 17:32, 3F
→
01/08 09:25, , 4F
01/08 09:25, 4F