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

    Get Number Of COM Ports

    Hi,

    How can I know dynamically how many COM Ports are attached to the System. Is there any API through which I can achieve This..

    Pl. Let me Know

    Regards

    Madhav


  2. #2
    Join Date
    Apr 1999
    Location
    Madrid (Spain)
    Posts
    46

    Re: Get Number Of COM Ports

    Hi:
    You can get this information reading the Windows registry file.

    The information, that you are looking for is in:
    HKEY_LOCAL_MACHINE\hardware\devicemap\SerialComm

    For reading the Windows registry file you can use the following functios:

    RegOpenKeyEx, RegQueryValueEx and RegCloseKey

    I hope that this information will be useful for you
    Good Luck, Bye....



  3. #3
    Join Date
    May 1999
    Location
    israel
    Posts
    52

    Re: Get Number Of COM Ports

    Hi Miguel,
    I would like to know if these functions are API and if yes what parameters do they have or what constants do they have??
    Thank-you!!


    LED

  4. #4
    Guest

    Re: Get Number Of COM Ports

    Hi Lior:
    These functions are API and following you can see the declarations in your Visual Basic program.

    private Declare Function RegCloseKey Lib "advapi32.dll" (byval hKey as Long) as Long

    private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (byval hKey as Long, byval lpValueName as string, byval lpReserved as Long, lpType as Long, lpData as Any, lpcbData as Long) as Long

    private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (byval hKey as Long, byval lpSubKey as string, byval ulOptions as Long, byval samDesired as Long, phkResult as Long) as Long



    Anyway you can find information about these functions in the Visual Studio help file. If you have any problem, don´t doubt to contact with me.

    Good luck, bye....


  5. #5
    Join Date
    Apr 1999
    Location
    Madrid (Spain)
    Posts
    46

    Re: Get Number Of COM Ports

    Hi Lior:
    I don´t know if you have received my post fine, for this reason I replay again

    These functions are API and following you can see the declarations in your Visual Basic program.


    private Declare Function RegCloseKey Lib "advapi32.dll" (byval hKey as Long) as Long
    private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (byval hKey as Long, byval lpValueName as string, byval lpReserved as Long, lpType as Long, lpData as Any, lpcbData as Long) as Long
    private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (byval hKey as Long, byval lpSubKey as string, byval ulOptions as Long, byval samDesired as Long, phkResult as Long) as Long






    Anyway you can find information about these functions in the Visual Studio help file. If you have any problem, don´t doubt to contact with me.

    Good luck, bye....
    Miguel





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