Click here to Skip to main content
11,706,455 members (32,729 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# COM port
I can access any COM Port using SerialPort class in c#

and also i can use the CreateFile API to get handle for Com and use to communicate with

is this a difference between these two method?

as if i can't do connection to Com using SerialPort can i do this using CreateFile API?
Posted 18-Jun-13 23:27pm
Comments
du[DE] at 19-Jun-13 7:03am
   
I fear that is not the right way, you need to understand why you can't do connection using SerialPort... What is the trouble here, can you get some code and the exactly error?
Amitosh Swain at 19-Jun-13 7:49am
   
He's asking the difference between the two
Jochen Arndt at 19-Jun-13 8:38am
   
I'm not absolutely sure but believe that the SerialPort class uses the common API functions for serial I/O internally (CreateFile, ReadFile, WriteFile, SetCommXXX). So there should be no difference regarding the communication itself.
du[DE] at 19-Jun-13 8:56am
   
I think that too, Jochen - that will be surely the same API in the end (CreateFile)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

CreateFile to COM port, sometimes requires admin access (not always).
SerialPort is the preferred way since it allows you to cotrol various other niche options too, that isn't easily available in CreateFile

See MSDN[^] for details.
  Permalink  
v2
Comments
du[DE] at 19-Jun-13 8:37am
   
>CreateFile to COM port, sometimes requires admin access (not always). Yea, only on bad days (Sundays and Saturdays usually not ;)
Amitosh Swain at 19-Jun-13 11:31am
   
I have ran into that sort of things... while opening a Bluetooth COM port

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 197
1 Sergey Alexandrovich Kryukov 141
2 chainerlt 110
3 Mika Wendelius 80
4 ppolymorphe 71
0 OriginalGriff 9,070
1 Sergey Alexandrovich Kryukov 8,413
2 CPallini 5,189
3 Maciej Los 4,746
4 Mika Wendelius 3,676


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 19 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100