Hi, Write WndProc in the code and check for device attached/detached event.(There is one event for this. Try to search on net.) After getting event write a code to read registry for com port information. When an device is plugged to USB port an entry is made in the registry.
HKEY_LOCAL_MACHINE/DEVICEMAP/SERIALCOMM
So, you can listen for the changes in this key. And will get to know com port at which device is attached.