Das ansprechen des COMPorts unter c ist eigentlich recht einfach.
Danach kannst du den Filedeskriptor wie eine Datei verwenden.Code://===========================================================================// // Copyright 01.05 Michael Sonst für Systeme Helmholz GmbH, Weisendorf // // // // Autor : Michael Sonst // // Version : 1.1 // // Erstellt am : 21.01.2005 // // // //===========================================================================// s8 IsWinNT() { OSVERSIONINFO OSinfo; OSinfo.dwOSVersionInfoSize = sizeof(OSinfo); GetVersionEx(&OSinfo); return(OSinfo.dwPlatformId == VER_PLATFORM_WIN32_NT); } //--------------------------------------------------------------------------- void __fastcall EnumComPorts(TComboBox* combobox) { if(combobox==NULL)return; combobox->Clear(); s8 Name[16]; HANDLE hCom; u8 maxport; if(IsWinNT())maxport=99; else maxport=9; for(s32 i=0; i<maxport; i++){ Name[0] = '\0'; strcat(Name, "COM"); strcat(Name, IntToStr(i).c_str()); hCom = CreateFile ( Name, // name of comport (GENERIC_READ | GENERIC_WRITE), // access mode 0, // only exclusive open a comport NULL, // security none OPEN_EXISTING, // only if exist FILE_FLAG_OVERLAPPED, // open with overlapped structure FILE_ATTRIBUTE_NORMAL 0); // always zero if(hCom != INVALID_HANDLE_VALUE){ combobox->AddItem("COM"+IntToStr(i), (TObject*)i); //abuse TObject CloseHandle(hCom); } } }
Schau dir doch mal die im quellcode verfügbaren Komponenten an.
(www.torry.com)
Gruss
Michael





Zitieren

Lesezeichen