VS2005下Unicode的CreateFile问题
用CSerialPort在VC6下编译没有问题。现在在VS2005下面编译使用Use Unicode Character Set方式出错如下。
C2664: 'CreateFileW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'
char *szPort = new char[50];
m_hComm = CreateFile(szPort, // communication port string (COMX)
GENERIC_READ | GENERIC_WRITE, // read/write types
使用m_hComm = CreateFile((LPCWSTR)szPort,....
强制转换后,初始化串口失败.在VC6下功能没有问题。我单步调试到CreateFile时候显示szPort是"COM4"与VC6下一样,为何VS2005下失败呢。