PC Review


Reply
Thread Tools Rate Thread

GetDefaultCommConfig VB v C#

 
 
rollasoc
Guest
Posts: n/a
 
      19th Feb 2004
Hi,

I'm trying to get a list of COM ports on my machine using the API
GetDefaultCommConfig.

I've found an example in VB of how to do this but wanted to C# it up.

This works fine but is very slow in C#

In VB it searches for 16 COM Ports in less than a second.

In C# it searches for 10 COM Ports in about 3 seconds.

Why the difference in speed?

I did note in the Output window that the VB does the following once

'WindowsApplication2.exe': Loaded
'c:\winnt\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\mi
crosoft.visualbasic.dll', No symbols loaded.

In C# I get the following in the Output window for each iteration

'MyApp.exe': Loaded 'C:\WINNT\system32\cfgmgr32.dll', No symbols loaded.
'MyApp.exe': Unloaded 'C:\WINNT\system32\cfgmgr32.dll'

plus several
'MyApp.exe': Loaded 'C:\WINNT\system32\serialui.dll', No symbols loaded.
'MyApp.exe': Unloaded 'C:\WINNT\system32\serialui.dll'

I'm assuming the extra time being taken is in the loading and unloading of
the libraries many many times.

How can I speed this up? (Seems a bit daft to have to create a whole VB
DLL just for one function call.

Any ideas?

Rollasoc














 
Reply With Quote
 
 
 
 
BuddyWork
Guest
Posts: n/a
 
      19th Feb 2004
If you just want a list of COM ports on your machine then
use the Windows API EnumPorts, I've added a link to a
similar message.

http://groups.google.com/groups?hl=e...=UTF-8&oe=UTF-
8&threadm=85LT7hUkDHA.1928%
40cpmsftngxa06.phx.gbl&rnum=2&prev=/groups%3Fq%3Ddotnet%
2Bhow%2Bto%2Bget%2BCOM%2Bports%26hl%3Den%26lr%3D%26ie%
3DUTF-8%26oe%3DUTF-8%26selm%3D85LT7hUkDHA.1928%
2540cpmsftngxa06.phx.gbl%26rnum%3D2

Hope this helps.

>-----Original Message-----
>Hi,
>
>I'm trying to get a list of COM ports on my machine using

the API
>GetDefaultCommConfig.
>
>I've found an example in VB of how to do this but wanted

to C# it up.
>
>This works fine but is very slow in C#
>
>In VB it searches for 16 COM Ports in less than a second.
>
>In C# it searches for 10 COM Ports in about 3 seconds.
>
>Why the difference in speed?
>
>I did note in the Output window that the VB does the

following once
>
>'WindowsApplication2.exe': Loaded
>'c:\winnt\assembly\gac\microsoft.visualbasic\7.0.5000.0__b

03f5f7f11d50a3a\mi
>crosoft.visualbasic.dll', No symbols loaded.
>
>In C# I get the following in the Output window for each

iteration
>
>'MyApp.exe': Loaded 'C:\WINNT\system32\cfgmgr32.dll', No

symbols loaded.
>'MyApp.exe': Unloaded 'C:\WINNT\system32\cfgmgr32.dll'
>
>plus several
>'MyApp.exe': Loaded 'C:\WINNT\system32\serialui.dll', No

symbols loaded.
>'MyApp.exe': Unloaded 'C:\WINNT\system32\serialui.dll'
>
>I'm assuming the extra time being taken is in the loading

and unloading of
>the libraries many many times.
>
>How can I speed this up? (Seems a bit daft to have to

create a whole VB
>DLL just for one function call.
>
>Any ideas?
>
>Rollasoc
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>.
>

 
Reply With Quote
 
 
 
 
rollasoc
Guest
Posts: n/a
 
      19th Feb 2004
Cheers I'll check it out.

I did try using the System.Management namespace functions, but that could
only see physical COM ports on the machine and none of the USB To Serial
type COM Ports. GetDefaultCommConfig appears to give me these.

Rollasoc

"BuddyWork" <(E-Mail Removed)> wrote in message
news:1264701c3f6e3$a4abd6c0$(E-Mail Removed)...
> If you just want a list of COM ports on your machine then
> use the Windows API EnumPorts, I've added a link to a
> similar message.
>
> http://groups.google.com/groups?hl=e...=UTF-8&oe=UTF-
> 8&threadm=85LT7hUkDHA.1928%
> 40cpmsftngxa06.phx.gbl&rnum=2&prev=/groups%3Fq%3Ddotnet%
> 2Bhow%2Bto%2Bget%2BCOM%2Bports%26hl%3Den%26lr%3D%26ie%
> 3DUTF-8%26oe%3DUTF-8%26selm%3D85LT7hUkDHA.1928%
> 2540cpmsftngxa06.phx.gbl%26rnum%3D2
>
> Hope this helps.
>
> >-----Original Message-----
> >Hi,
> >
> >I'm trying to get a list of COM ports on my machine using

> the API
> >GetDefaultCommConfig.
> >
> >I've found an example in VB of how to do this but wanted

> to C# it up.
> >
> >This works fine but is very slow in C#
> >
> >In VB it searches for 16 COM Ports in less than a second.
> >
> >In C# it searches for 10 COM Ports in about 3 seconds.
> >
> >Why the difference in speed?
> >
> >I did note in the Output window that the VB does the

> following once
> >
> >'WindowsApplication2.exe': Loaded
> >'c:\winnt\assembly\gac\microsoft.visualbasic\7.0.5000.0__b

> 03f5f7f11d50a3a\mi
> >crosoft.visualbasic.dll', No symbols loaded.
> >
> >In C# I get the following in the Output window for each

> iteration
> >
> >'MyApp.exe': Loaded 'C:\WINNT\system32\cfgmgr32.dll', No

> symbols loaded.
> >'MyApp.exe': Unloaded 'C:\WINNT\system32\cfgmgr32.dll'
> >
> >plus several
> >'MyApp.exe': Loaded 'C:\WINNT\system32\serialui.dll', No

> symbols loaded.
> >'MyApp.exe': Unloaded 'C:\WINNT\system32\serialui.dll'
> >
> >I'm assuming the extra time being taken is in the loading

> and unloading of
> >the libraries many many times.
> >
> >How can I speed this up? (Seems a bit daft to have to

> create a whole VB
> >DLL just for one function call.
> >
> >Any ideas?
> >
> >Rollasoc
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >.
> >



 
Reply With Quote
 
rollasoc
Guest
Posts: n/a
 
      19th Feb 2004
http://tinyurl.com/2u8kw

for an easier link


"BuddyWork" <(E-Mail Removed)> wrote in message
news:1264701c3f6e3$a4abd6c0$(E-Mail Removed)...
> If you just want a list of COM ports on your machine then
> use the Windows API EnumPorts, I've added a link to a
> similar message.
>
> http://groups.google.com/groups?hl=e...=UTF-8&oe=UTF-
> 8&threadm=85LT7hUkDHA.1928%
> 40cpmsftngxa06.phx.gbl&rnum=2&prev=/groups%3Fq%3Ddotnet%
> 2Bhow%2Bto%2Bget%2BCOM%2Bports%26hl%3Den%26lr%3D%26ie%
> 3DUTF-8%26oe%3DUTF-8%26selm%3D85LT7hUkDHA.1928%
> 2540cpmsftngxa06.phx.gbl%26rnum%3D2
>
> Hope this helps.
>
> >-----Original Message-----
> >Hi,
> >
> >I'm trying to get a list of COM ports on my machine using

> the API
> >GetDefaultCommConfig.
> >
> >I've found an example in VB of how to do this but wanted

> to C# it up.
> >
> >This works fine but is very slow in C#
> >
> >In VB it searches for 16 COM Ports in less than a second.
> >
> >In C# it searches for 10 COM Ports in about 3 seconds.
> >
> >Why the difference in speed?
> >
> >I did note in the Output window that the VB does the

> following once
> >
> >'WindowsApplication2.exe': Loaded
> >'c:\winnt\assembly\gac\microsoft.visualbasic\7.0.5000.0__b

> 03f5f7f11d50a3a\mi
> >crosoft.visualbasic.dll', No symbols loaded.
> >
> >In C# I get the following in the Output window for each

> iteration
> >
> >'MyApp.exe': Loaded 'C:\WINNT\system32\cfgmgr32.dll', No

> symbols loaded.
> >'MyApp.exe': Unloaded 'C:\WINNT\system32\cfgmgr32.dll'
> >
> >plus several
> >'MyApp.exe': Loaded 'C:\WINNT\system32\serialui.dll', No

> symbols loaded.
> >'MyApp.exe': Unloaded 'C:\WINNT\system32\serialui.dll'
> >
> >I'm assuming the extra time being taken is in the loading

> and unloading of
> >the libraries many many times.
> >
> >How can I speed this up? (Seems a bit daft to have to

> create a whole VB
> >DLL just for one function call.
> >
> >Any ideas?
> >
> >Rollasoc
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get GetDefaultCommConfig to work with VB.NET? Joe HM Microsoft VB .NET 1 13th Apr 2006 10:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:57 PM.