الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

برنامج جيد لفحص المنافذ التسلسلية المتوفرة

مغلق
بدأه g-johnny في 11 يونيو 2004 · 0 رد · 476 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1

CreateFile can not only be used to create and open files, but also to access COM ports, system devices, services, or consoles. By applying it to COM ports, a simple routine can enumerate probable COM ports return

ing the availability of a given port. The code presented here contains two key functions.

GetInstalledCOMPorts() passes a series of port numbers (1 through 16 in this demo) to the worker COMCheckPort function, which uses CreateFile to open a COM port returning True or False if a file handle was obtained for each of the the specified COM ports. The function closes the port immediately after the call so as to restore the system to its available state. The results of each call are entered to a list indicating which ports are available for use.

GetFirstAvailableCOMPort() also uses COMCheckPort as well, but this routine exits once the first available port has been determined. For demo purposes the result is displayed in the list box as well.

The Open COM/Close COM buttons open COM1 (if available/unused) to demo how the code works against different COM port states. Also included is the API call to display the ConfigurePort dialog allowing the user to customize the COM port baud rate, bits, parity, stop bits and flow control, as well as restore the default settings. As ConfigurePort only shows the config dialog, no data changed or set by the user is returned. Rather, the dialog returns 1 (vbOK) if the OK button was pressed, or 0 if cancelled (not vbCancel - that has a value of 2!).

com.rar

مهندس اتصالات

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…