I have written a code as suggested(from the link: http://www.codeproject.com\ce\mobileconnect.asp).
but i want to know how my pc will automatically detect the mobile connected via usb and give a notification that it is connected or not .
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.