Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Code Samples & Tips
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.


Reading com ports information from the registry


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-29-2007, 07:50 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,849
Default Reading com ports information from the registry

This is an example of finding the available serial ports (and their descriptions) from the registry.
Attached Files
File Type: zip ComPorts.zip (7.3 KB, 71 views)
Reply With Quote
  #2 (permalink)  
Old 06-04-2007, 01:35 PM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Default

Hi Erel
Thanks so much for your fantastic snippet!
It supports my therory about scanning GPS devices in a more elegant way.
I have modified the code to allow recognition of PnpId of external devices, such as CF GPS cards and further to show the Key entry if no FriendlyName available.
Cheers
Robert

Code:
Sub Globals
  Dim subKeys(0),values(0)
  Dim id, fn
End Sub

Sub App_Start
  Form1.Show
  Reg.New1
  Reg.RootKey(Reg.rtLocalMachine)
  If Not(cPPC) Then
    MsgBox("This application is not supported on the desktop.")
    AppClose
  End If
  al1.Clear  'for repeated queries
  subKeys() = Reg.GetSubKeyNames("Drivers\Active") 'Gets the list of active drivers.
  For i = 0 To ArrayLen(SubKeys())-1
    values() = Reg.GetValueNames("Drivers\Active\" & subKeys(i))
    For i2 = 0 To ArrayLen(values())-1
      If values(i2) = "Name" Then 'Checks if Name value exists.
        name = Reg.GetValue("Drivers\Active\" & subKeys(i),"Name")
        If SubString(name,0,3) = "COM" Then  'Checks if the driver name starts with COM.
          key = Reg.GetValue("Drivers\Active\" & subKeys(i),"Key")
          fn = reg.GetValue(key,"FriendlyName")
          id = Reg.GetValue("Drivers\Active\" & subKeys(i),"PnpId")
          If fn = "" Then fn = key           'Use Key if no FriendlyName available
          If StrLength(id) > 0 Then fn = ""  'Prefer PnpId over Key'
          al1.Add(name & " " & fn & id)      'Gets the FriendlyName value and PnpId, if available.
        End If
        Exit
      End If
    Next
  Next		
  al1.Sort(cCaseUnsensitive) 'Sorts the values.
  ListBox1.Clear    'for repeated queries
  For i = 0 To al1.Count-1
    ListBox1.Add(al1.Item(i)) 'Adds the values to the ListBox.
  Next
End Sub

Last edited by alfcen : 11-23-2007 at 01:06 PM.
Reply With Quote
  #3 (permalink)  
Old 06-04-2007, 04:12 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,849
Default

Thanks.
The credits go to ukiller from OpenNETCF forums: http://www.opennetcf.org/forums/topi...find,gps,,port
Reply With Quote
  #4 (permalink)  
Old 11-23-2007, 08:57 AM
Newbie
 
Join Date: Nov 2007
Posts: 6
Default USB port scanner

Hi, what about USB scanner ?
I want to use iPod as external data storage, but it not work property without additional drivers. And I decided that I should write drivers myself, but I don't now how to scan USB ports.
Reply With Quote
  #5 (permalink)  
Old 11-23-2007, 01:09 PM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Default

Hi Angor,

On an iPAQ (PPC 2003SE), the above routine will reveal

COM9: Serial on USB

Maybe it helps knowing to which port USB is tied.

Cheers
Robert
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
FilesEx library - returns file information agraham Additional Libraries 13 07-25-2008 04:23 PM
Reading Registry Keys - Bug or Mistake? Raytracer Questions & Help Needed 1 04-18-2008 04:31 PM
reading and editing registry Dr. Feelgood Questions & Help Needed 3 02-16-2008 07:18 AM
Save information drawn on a form maxtillberg Questions & Help Needed 10 11-07-2007 11:13 AM
How to set the Version Information in the exe file ? XerVision Questions & Help Needed 1 08-10-2007 07:01 AM


All times are GMT. The time now is 07:09 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0