CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: COM Port Handle

  1. #1
    Join Date
    Apr 2005
    Posts
    1,828

    COM Port Handle

    What is the Win32 command for writing to a com port handle??

  2. #2
    Join Date
    May 2000
    Location
    NJ
    Posts
    640

    Re: COM Port Handle

    Code:
    // Open Com Port
    HANDLE	_hSerialComm = CreateFile("\\\\.\\COM1",
    			GENERIC_READ|GENERIC_WRITE,
    			0,
    			0,
    			OPEN_EXISTING,
    			FILE_ATTRIBUTE_NORMAL |
    			FILE_FLAG_OVERLAPPED,
    			0);
    
    // Read the Com Port
    DWORD dwLength, cb;
    OVERLAPPED _osSerial;
    
    
    ReadFile(_hSerialComm,buffer,dwLength,&cb,&_osSerial);
    
    // Write to Com Port
    
    WriteFile(_hSerialComm, buffer, dwLength, &cb,&_osSerial);
    There are examples on CodeGuru for Serial Port Communications.

  3. #3
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    628

    Re: COM Port Handle

    createfile to get a handle
    readfile to read from port
    writefile to write to port

    a very very very very very helpful tutorial:
    http://www.daniweb.com/techtalkforum...ead.php?t=8020

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured