codice:struct writeParams { HANDLE hComm; char * buf; }; BOOL write(HANDLE hComm, char * buf) { DWORD nNumberOfBytesToWrite = strlen(buf); DWORD NumberOfBytesWritten; LPOVERLAPPED lpOverlapped = NULL; BOOL res = WriteFile( hComm, buf, nNumberOfBytesToWrite, &NumberOfBytesWritten, lpOverlapped ); if (res) cout << "Scrittura OK " << endl; else { DWORD err = GetLastError(); cout << "Errore in Scrittura " << err; } return res; } DWORD WINAPI WriteThreadProc (LPVOID lpParameter) { writeParams * wp=(writeParams *)lpParameter; return (DWORD) write(wp->hComm,wp->buf); } int main (int argc, char* argv[]) { //... writeParams wp; wp.hComm=quello che ci devi mettere; wp.buf=quello che ci devi mettere; HANDLE hWriteThread = CreateThread(NULL, 0, WriteThreadProc, &wp, 0, NULL); //... }

Rispondi quotando