电竞比分网-中国电竞赛事及体育赛事平台

分享

vfp如何使用FOXTOOLS.FLL的OpenComm() 函式

 Alkaid2015 2013-11-03
OpenComm() 是可以使用 FOXTOOLS 呼叫的函式。若要開啟 COM 或 LPT 連接埠 FLL。下面是 OpenComm() 的完整說明。
 
用途
OpenComm() 函式會開啟通訊裝置。

函式語法

   OpenComm(<port>, <in_q>, <out_q>)

   Argument       Description
   -----------------------------------------------------------------

   <port>         Points to a null-terminated string that specifies
                  the device in the form COM<n> or LPT<n>, where <n>
                  is the device number.

   <in_q>         Specifies the size, in bytes, of the receiving
                  queue. This parameter is ignored for LPT devices.

   <out_q>        Specifies the size, in bytes, of the transmission
                  queue. This parameter is ignored for LPT devices.
				

傳回

如果函式成功,傳回的值會識別開啟裝置。否則,它是小於零。

錯誤

如果函式失敗,它可能會傳回下列的錯誤值的其中一個:
   Value     Meaning
   --------------------------------------------------------------------

   -12       The device's baud rate is unsupported.
   -11       The specified byte size is invalid.
   -10       The hardware is not available (is locked by another device).
    -5       The default parameters are in error.
    -4       The function cannot allocate the queues.
    -3       The device is not open.
    -2       The device is already open.
    -1       The device identifier is invalid or unsupported.
				
如果此函式呼叫與同時佇列大小設(shè)定為零,則傳回值是-2,如果裝置已經(jīng)開啟,或-4 如果裝置是不開啟。

註解

Windows 允許 COM 連接埠 1 到 9 及 LPT 連接埠 1 到 3。如果裝置驅(qū)動程式不支援通訊連接埠號碼,將會失敗的 OpenComm() 函式。

範例程式碼

下列程式碼範例會使用 OpenComm() 函式和 FOXTOOLS。若要開啟 COM1 的 FLL。(本範例可以在 FOXPROW\GOODIES\FOXTOOLS\DIALER 中找到。PRG。)
   *-------------------- dialer.prg ------------------------

   * Sample program to output to comm port
   * Uses FoxTools library for generic DLL access

   SET LIBRARY TO SYS(2004)+"foxtools.fll" ADDITIVE

   opencomm = REGFN("OpenComm", "CII", "I")
   writecomm = REGFN("WriteComm", "ICI", "I")
   closecomm = REGFN("CloseComm", "I", "I")

   com1 = CALLFN(opencomm, "COM1:", 100, 100)
   s = "ATDT 5551212" + chr(13)
   =CALLFN(writecomm, com1, s, len(s))

   WAIT WINDOW "Press any key to hang up"
   s = "ATH0" + chr(13)
   =CALLFN(writecomm, com1, s, len(s))

   =CALLFN(closecomm, com1)

   RELEASE LIBRARY SYS(2004)+"foxtools.fll"
				
附註: Windows 的 Visual FoxPro OpenComm() 函式的適用性,對照 32 位元 Foxtools.fll 傳回的控制碼 RegFN() 呼叫前提是它會傳遞選擇性的第四個引數(shù),也就是 「 使用者。DLL。"以下是範例:
   hnd = RegFN("OpenComm","CCC","I","User.dll")

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多