2011年4月6日 星期三

在BCB中之ComPort 設定

來源網址 

找了很久才找到的解法~

在BCB 6.0中,若使用ComPort 4.11,設定Port時所遇到的問題。
錯誤訊息大致如下

unresolved external ...fastcall SetPortA...

而錯誤的程式碼如下

ComPort->Port = "COM8";

解決方式就是修改
C:\Program Files\Borland\CBuilder6\Include\winspool.h

在此檔案找到下面內容


BOOL

WINAPI

SetPortA(

IN LPSTR     pName,

IN LPSTR     pPortName,

IN DWORD       dwLevel,

IN LPBYTE      pPortInfo

);

BOOL

WINAPI

SetPortW(

IN LPWSTR     pName,

IN LPWSTR     pPortName,

IN DWORD       dwLevel,

IN LPBYTE      pPortInfo

);

#ifdef UNICODE

#define SetPort  SetPortW

#else

#define SetPort  SetPortA

#endif // !UNICODE

然後在頭尾分別加上

#ifdef DONT_USE_WINSPOOL_SETPORTA


#endif //!DONT_USE_WINSPOOL_SETPORTA
成為

#ifdef DONT_USE_WINSPOOL_SETPORTA
SetPortA(
...
...
#endif // !UNICODE
#endif //!DONT_USE_WINSPOOL_SETPORTA
存檔後,重新compile即可。

沒有留言:

搜尋此網誌