VC serial control programming, resolving the increasing number of memory: Name: Wang Chaojie If you need to reprint, please contact the author. Chaojie2003@yahoo.com.cn
Development Environment: VC6 Windows 2000 Explanation: Many people often encounter when serial accepted data is relatively large, from Windows 2000 Task Manager, can see the memory of the program occupied by the program. Increase, I have to transfer the API from the new writing. This article mainly solves this problem. When writing a serial control to receive data, it is written: // Initial setting m_mscomm.setcommport (1) // Open COM1M_MSCOMM.SETPORTOPEN (TRUE); / / Open the serial port m_mscomm.setSettings ("115200, n, 8, 1"); // Serial port parameter setting m_mscomm.setinputMode (1); // CominputModeBinary Set Binary Buffer Input mode m_mscomm.sethreshold (5); // Each received 5 characters excited oncomm () event m_mscomm.setinputlen (5); // read 5 characters // receive data Void ccomdlg :: oncomm () {variant variant_inp; ColesafeArray Safearray_inp; Long Len, K; Byte RxData [5]; // Set the BYTE array cstring strTemp; switch (m_mscomm.getCommEvent ()) {case 2: // Event value 2 indicates that the receiving buffer has character variant_inp = m_mscomm.getinput (); // Read buffer ------------------------------- * SafeArray_inp = variant_inp; // variant type variable converted to COLESAFEARRAY Type Variable Len = SafeArray_inp .Getonedimsize (); // Verify resulting the valid data length assert (len == 5); for (k = 0; k