Applies ToGeneral

摘要

Createfile 可用來取得序列連接埠的控制代碼。「 Win32 程式設計人員參考 」 的 「 Createfile 」 項目提及的共用模式必須是 0、 建立參數必須是 OPEN_EXISTING,以及範本必須是 NULL。當您使用 "COM1" 到 "COM9" 作為檔案的名稱時,CreateFile() 成功。不過,訊息

INVALID_HANDLE_VALUE

將會在您使用 "COM10" 或以上時回傳。如果連接埠的名稱是 \\.\COM10,呼叫 Createfile 中指定的序列連接埠的正確方式如下: CreateFile( "\\\\.\\COM10", // address of name of the communications device fdwAccess, // access (read-write) mode 0, // share mode NULL, // address of security descriptor OPEN_EXISTING, // how to create 0, // file attributes NULL // handle of file with attributes to copy ); 附註: 此語法也適用於透過 COM9 的 COM1 連接埠。某些版可讓您選擇的連接埠名稱自己。這個語法適用於這些名稱也中。

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。