All I found the way to remove unused COM port is use device manager, right-click it and remove.
But I need to remove them by c/c++.
I tried to delete reg Computer\