Running Another Application As A Process

  using namespace System::Diagnostics;   Create Process if (File::Exists("C:\\Program Files\\Some Folder\\SomeApp.exe")) { Process1 = gcnew Process(); Process1->StartInfo->FileName = "C:\\Program Files\\Some Folder\\SomeApp.exe"; Process1->StartInfo->Arguments = ""; Process1->Start(); Process1->WaitForInputIdle(); }   Is Process Active if ((Process1 != nullptr) && (!Process1->HasExited)) {   Close The Process if ((Process1 != nullptr) && (!Process1->HasExited)) { //Process1->CloseMainWindow(); //Process1->Close(); Process1->Kill(); //Use this instead […]

Read More

Is String Value Numeric

  int i = 0; bool ValueIsNumeric = int::TryParse(MyStringValue, i); For larger values: UInt64 i = 0; ValueIsNumeric = UInt64::TryParse(MyStringValue, i);    

Read More

Checkbox General

Item Value Changed private: System::Void CheckboxSetLedChanged (System::Object^ sender, System::EventArgs^ e) { System::Windows::Forms::CheckBox ^CallingCheckBox = safe_cast<System::Windows::Forms::CheckBox^>(sender); if (CallingCheckBox->Checked) { } }    

Read More

Versions of C++

Intellisense Removed in VS 2010 WTF!  Returned in 2012 Good Resources yosoygames, microsoft-we-need-to-talk-about-visual-studio

Read More

FTP File Download

Simple FTP File Download using namespace System::IO; //Used for FTP using namespace System::Net; //Used for FTP array<Byte>^FtpFileData; WebClient^ request = gcnew WebClient; request->Credentials = gcnew NetworkCredential("MyUsername","MyPassword"); try { FtpFileData= request->DownloadData("ftp://1.2.3.4/SomeDirectory/MyFile.csv"); } catch (WebException^ e) { FtpFileData= gcnew array<Byte>(0); }      

Read More

Refresh Form

To cause form controls such as a text box to be refreshed after updating them before your code goes and does something time consuming and intensive you can use this: this->Refresh(); This does work, if it doesn't try adding a System::Threading::Thread::Sleep(200) after it.

Read More

Timer Threads

System.Windows.Forms.Timer will execute in the UI thread System.Timers.Timer executes in a thread-pool thread unless you specify a SynchronizingObject System.Threading.Timer executes its callback in a thread-pool thread

Read More

Convert Pasted List Into Array Of Strings

  array<String^> ^NewUsernames = NewUsernames = gcnew array<String^>(0); String ^sPastedString; String ^sName; String ^sMarker = "[MARKERdfghj23l]"; int Count; try { sPastedString = txtPasteUsernames->Text; txtPasteUsernames->Text = ""; sPastedString = sPastedString->Trim(); if (sPastedString->Length <= 1) //Ignore single character in case user tries to type into box return; //Place markers between each name sPastedString = sPastedString->Replace("\r\n", sMarker); sPastedString […]

Read More

Specific USB Devices

  How To Find Specific USB Devices That Are Connected This example works by looking for a specific USB device VID and PID and was made to work with devices using Microchips USB CDC USB firmware stack.  However it will work with all sorts of USB devices. using namespace System::IO::Ports; //< Needed for USB serial port […]

Read More

Send Keys

The SendKeys class can be used to send keystrokes to the currently active window SendKeys::Send("{F12}");    To specify keys combined with any combination of SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following:      For SHIFT prefix with +    For CTRL  prefix with ^    For […]

Read More