線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2138
推到 Plurk!
推到 Facebook!

並列通訊程式碼

答題得分者是:qoo1234
Patric_Chuang
一般會員


發表:5
回覆:12
積分:3
註冊:2003-03-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-03-12 15:04:16 IP:211.75.xxx.xxx 未訂閱
請問各位先輩們,小弟我用IO.dll 2002(http://geekhideout.com/iodll.shtml)做並列通訊的控制,此 dll 附有.cpp及.h,小弟我先把此三個檔案放在我的專案資料夾內,在BCB程式中也將.cpp加入專案中,編譯可以成功,但在執行時會產生錯誤訊息,如 Access violation at address 00000000. Read of address 00000000  ,在98下也出現同樣的訊息,只是 Read of address 的位置不同,希望各位先輩們能夠撥空指導小弟,感激不盡,以下小弟附上程式碼,希望各位能夠幫幫忙....謝謝    以下為.cpp檔 #include  #pragma hdrstop #include "Unit1.h" #include "io.h" //---------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; long PtrAddress; int DataOutValue; //------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { PtrAddress=0x378; DataOutValue=1; } //------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { PortWordOut(PtrAddress,DataOutValue); } //------------------------------------------------------------------ 以下為.h檔 #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include Classes.hpp #include Controls.hpp #include StdCtrls.hpp #include Forms.hpp //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TButton *Button1; void __fastcall Button1Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif 麻煩各位先輩幫幫忙..........謝謝 發表人 -
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-03-12 15:24:35 IP:61.218.xxx.xxx 未訂閱
你先執行 LoadIODLL();
Patric_Chuang
一般會員


發表:5
回覆:12
積分:3
註冊:2003-03-02

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-03-12 17:25:11 IP:211.75.xxx.xxx 未訂閱
引言: 你先執行 LoadIODLL(); 小弟領悟力可能沒那麼好,無法瞭解前輩的意思,請問是否有完整的程式流程或>< face="Verdana, Arial, Helvetica">
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-03-12 17:32:32 IP:61.218.xxx.xxx 未訂閱
在 io.cpp 內有一個 LoadIODLL 及 UnloadIODLL __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { LoadIODLL(); PtrAddress=0x378; DataOutValue=1; } __fastcall TForm1::~TForm1() { UnloadIODLL(); }
Patric_Chuang
一般會員


發表:5
回覆:12
積分:3
註冊:2003-03-02

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-03-13 12:28:15 IP:61.59.xxx.xxx 未訂閱
感謝qoo1234兄的幫忙,在請教一下,此IO.dll在WIN2000下能工作嗎? 或是有別的類似此IO.dll可在2000下工作 謝謝
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-03-13 14:06:37 IP:61.218.xxx.xxx 未訂閱
此IO.dll可以在 WIN2000 下工作
Patric_Chuang
一般會員


發表:5
回覆:12
積分:3
註冊:2003-03-02

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-03-13 17:21:48 IP:211.75.xxx.xxx 未訂閱
引言: 此IO.dll可以在 WIN2000 下工作
同樣的寫法在Win98下可以執行,但小弟在Win2000編譯完成後,執行時會出現Privileged instruction的訊息,是否小弟我又有什麼地方寫錯或疏忽了,能否請qoo1234兄給予小弟我指導一下 謝謝
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-03-13 17:33:28 IP:61.218.xxx.xxx 未訂閱
Windows NT/2000 is accomodated through the use of a small kernel mode driver that releases the ports as needed to the application. This driver is embedded in the DLL and is installed if Windows NT/2000/XP is determined to be the underlying operating system. Due to the very minor overhead involved in dynamically linking to IO.DLL, and the optimized functions contained within, access to I/O ports is nearly as fast as if it was written in raw assembler and inlined in your application. This holds true for both Windows 95/98 and Windows NT/2000. Before moving on, it is probably prudent to mention that the technique employed in IO. DLL for releasing the ports to the application level isn't, strictly speaking, the proper way to do things. The proper way is to have a virtual device driver for Windows 95/98 and a kernel mode driver for Windows NT/2000. This isn't very practical for many people though, nor is it really necessary. There are several successful commercial products on the market that do exactly what IO. DLL does.
Patric_Chuang
一般會員


發表:5
回覆:12
積分:3
註冊:2003-03-02

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-03-13 20:42:44 IP:61.59.xxx.xxx 未訂閱
引言: Windows NT/2000 is accomodated through the use of a small kernel mode driver that releases the ports as needed to the application. This driver is embedded in the DLL and is installed if Windows NT/2000/XP is determined to be the underlying operating system. Due to the very minor overhead involved in dynamically linking to IO.DLL, and the optimized functions contained within, access to I/O ports is nearly as fast as if it was written in raw assembler and inlined in your application. This holds true for both Windows 95/98 and Windows NT/2000. Before moving on, it is probably prudent to mention that the technique employed in IO. DLL for releasing the ports to the application level isn't, strictly speaking, the proper way to do things. The proper way is to have a virtual device driver for Windows 95/98 and a kernel mode driver for Windows NT/2000. This isn't very practical for many people though, nor is it really necessary. There are several successful commercial products on the market that do exactly what IO. DLL does.
qoo1234兄,小弟還是無法很完全瞭解文章的含意,能否請您大概的講解一下 很抱歉又麻煩您 謝謝
ATEIN
高階會員


發表:105
回覆:320
積分:125
註冊:2002-07-05

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-03-16 18:08:11 IP:211.74.xxx.xxx 未訂閱
引言:
引言: 此IO.dll可以在 WIN2000 下工作
同樣的寫法在Win98下可以執行,但小弟在Win2000編譯完成後,執行時會出現Privileged instruction的訊息,是否小弟我又有什麼地方寫錯或疏忽了,能否請qoo1234兄給予小弟我指導一下 謝謝
晶片上有待觸發位元, 當受使用者觸發時,才會回應其所需位址狀態 這問題只要您觸發其位元即可解決問題 Dong-Han Mo.AtEin_ATTS
------
ATEIN
系統時間:2024-03-29 13:26:39
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!