Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I setup the OnClick enumerator part like this:

C++
ListBox1->Items->Clear();// <------- begin of 1st enumerate, from provided example
        res=BeginEnumeratePorts();
        while(TRUE)
         {
          if(!EnumeratePortsNext(res,buf))break;
          ListBox1->Items->Add(buf);
          i++;
         }
        EndEnumeratePorts(res);

ListBox1->Items->Clear();   // <------- begin of 2nd enumerate, identical to 1st one
        res=BeginEnumeratePorts();
        while(TRUE)
         {
          if(!EnumeratePortsNext(res,buf))break;
          ListBox1->Items->Add(buf);
          i++;
         }
        EndEnumeratePorts(res);

On the 2nd run, the enumerate fails to create the list done by 1st
1st list is
COM1
COM2

Why does the 2nd run not enumerate?

What I have tried:

I am using Borland C++ builder 5, and also exact same results using Visual Studio 2017 and VS2019.

I have examined the code, and all appears to be as documented by MS. There seems to be something static which is not being reset, for the 2nd run.
Posted
Updated 23-Aug-21 21:03pm
v2
Comments
Richard MacCutchan 24-Aug-21 3:08am    
I cannot find any reference to the three functions BeginEnumeratePorts, EnumeratePortsNext, EndEnumeratePorts. Are they from some third party library?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900