CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Driver Development
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Driver Development Discussions on the development of drivers.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old October 29th, 2009, 03:57 AM
    bidesh bidesh is offline
    Member
     
    Join Date: Dec 2006
    Posts: 37
    bidesh is an unknown quantity at this point (<10)
    Thumbs down Enumerating Non Plug and Play Legacy Com Ports

    Hi All,

    This is my first post in this forum. I have tried searching this forum to get answer to my question before posting.

    I would like ask that is there any process using which I can get the installed COM ports number with friendly name in windows system. The operating system would be Windows XP with service pack 1/2/3 and higher.

    I need to enumerate the installed non plug and play legacy com ports and display to the user for selection. Actually a device with RS232 interface would be communicating with the windows pc via RS232 ports. So my application need to find the available COM ports and connect to that for reading and writing.

    Can anybody tell me how can I enumerate the available COM ports?

    Another question is that the most of the recent laptops does not come up with RS232 / COM ports. Only USB ports available for serial communication, so I would like to ask that if I use an RS232 to USB converter hardware device do I have to connect to USB port or same RS232 port connection is needed?

    Thanks and Regards,
    Bidesh

    C/C++, Win32, COM developer
    Reply With Quote
      #2    
    Old October 30th, 2009, 07:49 AM
    Randor Randor is offline
    Member
     
    Join Date: Jan 2009
    Posts: 25
    Randor is an unknown quantity at this point (<10)
    Re: Enumerating Non Plug and Play Legacy Com Ports

    Hi Bidesh,

    This isn't really a device driver question. You can enumerate installed COM ports from usermode. Microsoft MVP PJ Naughter has written a class for enumerating COM ports. You can find his class here:

    http://www.naughter.com/enumser.html

    I did not understand your second question.

    Best Wishes,
    -David Delaune
    Reply With Quote
      #3    
    Old November 2nd, 2009, 04:02 AM
    bidesh bidesh is offline
    Member
     
    Join Date: Dec 2006
    Posts: 37
    bidesh is an unknown quantity at this point (<10)
    Re: Enumerating Non Plug and Play Legacy Com Ports

    Hi Randor,

    Thanks for your reply.

    My second question was if I did not find a DB9/COM port in any system and only USB ports are available then how would I read/write on COM port.

    I got the source code from www.naughter.com which is very helpful. There were plenty of ways mentioned to enumerate COM ports installed in a system.

    Is there any way using which I can determine that enumerated COM ports are being used by any application?

    Thanks again,
    Bidesh

    C/C++, Win32, COM developer
    Reply With Quote
      #4    
    Old November 2nd, 2009, 07:39 PM
    Randor Randor is offline
    Member
     
    Join Date: Jan 2009
    Posts: 25
    Randor is an unknown quantity at this point (<10)
    Re: Enumerating Non Plug and Play Legacy Com Ports

    Quote:
    Originally Posted by bidesh View Post
    Hi Randor,
    My second question was if I did not find a DB9/COM port in any system and only USB ports are available then how would I read/write on COM port.

    If a device or driver object describes itself as a COM port then you should be able to use it. My old laptop did not have any DB9 connectors or a UART controller and I was able to use USB to serial adaptors. Your usermode application will not know the difference.


    Quote:
    Originally Posted by bidesh View Post
    Is there any way using which I can determine that enumerated COM ports are being used by any application?

    Well try opening the COM port with exclusive access and CreateFile() will fail and GetLastError() will return ERROR_ACCESS_DENIED if the COM port is in-use.

    Best Wishes,
    -David Delaune
    Reply With Quote
      #5    
    Old November 3rd, 2009, 12:51 AM
    bidesh bidesh is offline
    Member
     
    Join Date: Dec 2006
    Posts: 37
    bidesh is an unknown quantity at this point (<10)
    Re: Enumerating Non Plug and Play Legacy Com Ports

    Hi Randor,

    Thank you very much. Now I would be able to enumerate and determine unused COM ports for my application.

    Thanks again.

    Regards,
    Bidesh

    C/C++, Win32, COM developer
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Driver Development


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:17 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009