Com Port

void OpenPort(LPCTSTR szPortNum)
{
    HANDLE hCom = CreateFile(szPortNum,          
                          GENERIC_READ | GENERIC_WRITE,
                          0,                    
                          NULL,                  
                          OPEN_EXISTING,        
                          FILE_FLAG_OVERLAPPED,  
                          NULL);                
}

What parameter should I pass to the above function if I were to open a com port (COM2) ?

I tried something like this :

OpenPort("Com2");

but the CreateFile() return an invalid handle.

Thank you!


kctan100Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
zonaConnect With a Mentor Commented:
Very simple,you should call your function case sensetivly.
OpenPort("COM2") instead of OpenPort("Com2");  
0
All Courses

From novice to tech pro — start learning today.