Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Get Handle for SerialPort

Posted on 2011-03-22
4
Medium Priority
?
1,290 Views
Last Modified: 2012-05-11
Does anyone know how to get a handle for a SerialPort.

I am trying to generate a IOCTL_SERIAL_GET_COMMSTATUS message.

I have seen that people say you can open(create new ?) the port as a file and so get a handle that way but I cannot see how to do this.
0
Comment
Question by:jetbet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:morgulo
ID: 35194317
Maybe use: SerialPort port = new SerialPort("COM1");
0
 

Author Comment

by:jetbet
ID: 35194328
What is the handle?
0
 
LVL 5

Accepted Solution

by:
morgulo earned 2000 total points
ID: 35196921
If you need handle you must use CreateFile from kernel32.dll
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(string lpFileName, System.UInt32 dwDesiredAccess, System.UInt32 dwShareMode, IntPtr pSecurityAttributes, System.UInt32 dwCreationDisposition, System.UInt32 dwFlagsAndAttributes, IntPtr hTemplateFile);

Open in new window


read this:
"Open and Close Port"
http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx
0
 

Author Closing Comment

by:jetbet
ID: 35201379
Just what I was looking for.

Thanks
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question