Hi,

I'm coding an application which communicate with a usb terminal,
when installing it, i note that it was on COM6 and is named 308

So, in configuration panel, I got : 308(COM6) in COM list.

But on customer PC, it will be COM6 like COM7 ...., so how can I look for the one used by looking for it's name : 308

I succefully list enable COM with :
Code:
	// Recup de la liste des port de communication
	CString sPort;
	BOOL bSuccess;
	HANDLE hPort;
	DWORD dwError;

	for (UINT i=1; i<256; i++){
		
		//sPort.Format(_T("\\\\.\\COM%d"), i);
		sPort.Format(_T("COM%d"), i);

		// Tentative d'ouverture du port
		hPort = ::CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
		if (hPort == INVALID_HANDLE_VALUE){
			dwError = GetLastError();

			// L'erreur vient elle du  fait que le port est  occupé par une autre  appli ?
			bSuccess = (dwError == ERROR_ACCESS_DENIED || dwError == ERROR_GEN_FAILURE || dwError == ERROR_SHARING_VIOLATION);
		}
		else {
			bSuccess = TRUE;
			CloseHandle(hPort);
		}
		if (bSuccess) m_comListe.AddString(sPort);
	}
	m_comListe.SetCurSel(0);
And for the moment, i give the user the choice to select it's COM in a combobox (comListe)

Does anyone have an idea to do that ?

Thanks all.