##// END OF EJS Templates
An other char to wchar conv
Jeandet Alexis -
r47:84df714fc1b4 qt
parent child
Show More
@@ -119,10 +119,11 rs232port_t rs232open(char* psPortName)
119 {
119 {
120 rs232port_t fd;
120 rs232port_t fd;
121 /* Char to Wchar conversion*/
121 /* Char to Wchar conversion*/
122 int len = strlen(psPortName),convlen;
122 int neededSize = MultiByteToWideChar(CP_ACP, 0, psPortName, -1, 0, 0);
123 wchar_t *wcstr = (wchar_t *)malloc((len*sizeof(wchar_t)) + 10);
123 wchar_t* wcstr = new wchar_t[neededSize];
124 mbstowcs_s(&convlen,wcstr,len, psPortName,len);
124 MultiByteToWideChar(CP_ACP, 0, charString, -1, wcstr, neededSize);
125 fd = (rs232port_t)CreateFile(wcstr,GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
125 fd = (rs232port_t)CreateFile(wcstr,GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
126 delete wcstr;
126 #ifdef RS232_debug
127 #ifdef RS232_debug
127 if(fd==(rs232port_t)INVALID_HANDLE_VALUE)
128 if(fd==(rs232port_t)INVALID_HANDLE_VALUE)
128 {
129 {
General Comments 0
You need to be logged in to leave comments. Login now