Using C++ in VS .NET, I can't find how to open serial ports for reading/writing.
More specifically, I am writing a VC++ .NET application (a "Windows Forms
Application"), and need to access a Serial Port (COM1, COM2, etc),
preferably by using standard file I/O ("stream" type access would be great).
The example in the response below was interesting, but it was for VB, not
VC++. I'd like to do this with a "Windows Forms Application" program, NOT
Win32 program, if at all possible.
For example, when I attempt to use the following code with a "Windows Forms
Application", I get run-time errors:
FileStream *fs = new FileStream(S"COM1", FileMode::OpenOrCreate);
StreamWriter *sw = new StreamWriter(fs);
The run time errors look like:
System.ArgumentException: FileStream will not open Win32 devices
such as disk partitions and tape drives. Don't use "\\.\" in your path.
at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share,
Int32 bufferSize, Boolean useAsync,
String msgPath, Boolean bFromProxy)
(etc., etc., etc.)
How do o
Ed Kaim [MSFT] - 04 Jul 2004 01:39 GMT
Try
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/default.aspx.
> Using C++ in VS .NET, I can't find how to open serial ports for
> reading/writing.
[quoted text clipped - 31 lines]
>
> How do o