|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Com port listingHi,
I'm looking for a way to get a list of all the com ports on a pc. It doesn't matter if they are free or not or if they are virtual of physical. Who can help me? I've tried google, but nothing clear yet... rg, Eric Hi,
You can use the wmi for that. The win32_portconnector class contains the info you are looking for. Add a reference to system.management. Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim mo As Management.ManagementObject moSearch = New Management.ManagementObjectSearcher("Select * from Win32_PortConnector") moReturn = moSearch.Get For Each mo In moReturn Dim strOut As String strOut = mo("ExternalReferenceDesignator").ToString If strOut.Length < 1 Then strOut = mo("InternalReferenceDesignator").ToString End If Debug.WriteLine(strOut) Next http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_portconnector.asp Ken ---------------------- "EMW" <some***@MikroZoft.com> wrote in message I'm looking for a way to get a list of all the com ports on a pc.news:42c6e2be$0$745$5fc3050@dreader2.news.tiscali.nl... Hi, It doesn't matter if they are free or not or if they are virtual of physical. Who can help me? I've tried google, but nothing clear yet... rg, Eric Thanks!
Show quoteHide quote "Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht news:ecadHc2fFHA.1048@tk2msftngp13.phx.gbl... > Hi, > > You can use the wmi for that. The win32_portconnector class > contains the info you are looking for. Add a reference to > system.management. > > Dim moReturn As Management.ManagementObjectCollection > > Dim moSearch As Management.ManagementObjectSearcher > > Dim mo As Management.ManagementObject > > moSearch = New Management.ManagementObjectSearcher("Select * from > Win32_PortConnector") > > moReturn = moSearch.Get > > For Each mo In moReturn > Dim strOut As String > strOut = mo("ExternalReferenceDesignator").ToString > If strOut.Length < 1 Then > strOut = mo("InternalReferenceDesignator").ToString > End If > Debug.WriteLine(strOut) > Next > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_portconnector.asp > > Ken > ---------------------- > "EMW" <some***@MikroZoft.com> wrote in message > news:42c6e2be$0$745$5fc3050@dreader2.news.tiscali.nl... > Hi, > > I'm looking for a way to get a list of all the com ports on a pc. > It doesn't matter if they are free or not or if they are virtual of > physical. > > Who can help me? > I've tried google, but nothing clear yet... > > rg, > Eric > > >
Does String mashal default to UnmanagedType.LPTStr
(newbie warning) vb.net, stdregprov, deletekey - Invalid cast Loop thru all subfolders and list all files under each use ADOX for this :-) Transparent Color in an Icon questions about VB.NET, and uses in education Is there code to convert a c# module to VB? Loading two separate instance of the same assembly score object property values against a decision rule created from from database table record values Adding points to a bitmap |
|||||||||||||||||||||||