1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "gl\glut.h"
#include "iostream"
#include "resource.h"
le bout de code à problème :
/* construction du nom du port, tentative d'ouverture */
sprintf_s(szCOM, "COM%d", nId);
int iLen= lstrlenA(szCOM);
BSTR lpcwstrCom = SysAllocStringLen(NULL, iLen);
::MultiByteToWideChar(CP_ACP, 0, szCOM, iLen, lpcwstrCom, iLen);
g_hCOM = CreateFilew(lpcwstrCom, GENERIC_READ|GENERIC_WRITE, 0, NULL,OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, NULL);
//... Faut liberer la memoire une fois qu'ona finit avec
::SysFreeString(lpcwstrCom); |
Partager