// and make sure you've got: CloseHandle(hSerial); return 0;