> TCHAR *szPort = (TCHAR*)(portname.c_str());
If TCHAR really is a wide character, then you need to do more than simply casting a pointer.