using namespace System; using namespace System::IO::Ports; public ref class MyForm : public System::Windows::Forms::Form { public: MyForm(void) { InitializeComponent(); findPorts(); } protected: private: System::IO::Ports::SerialPort^ serialPort1; #pragma region Windows Form Designer generated code void InitializeComponent(void) { this->components = (gcnew System::ComponentModel::Container()); this->serialPort1 = (gcnew System::IO::Ports::SerialPort(this->components)); } #pragma endregion private: void findPorts(void) { array<Object^>^ objectArray = SerialPort::GetPortNames(); } private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) { //add sender name String^ name = this->serialPort1->PortName; //grab text and store in send buffer String^ message = "hello"; //write to serial if (this->serialPort1->IsOpen) this->serialPort1->WriteLine(message); else this->textBox2->Text = "Port Not Opened"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)