|
If I were you, I'd look for an implementation such as this[^].
|
|
|
|
|
Try the version of this structure from pinvoke.net, which provides properties to get and set the individual bits:
http://pinvoke.net/default.aspx/Structures/DCB.html[^]
The SerialPort class[^] would be a better choice for .NET code. It gives you friendly properties for all of the settings from the DCB struct.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 30-Sep-15 8:42am.
|
|
|
|
|
|
Yes, you should be able to replace the DCB structure from that thread with the version from the pinvoke.net site.
P/Invoke doesn't care about methods, properties or events on a structure. It only cares about the raw bytes passed across. So long as the fields you're using produce the right bytes to send to the unmanaged method, it will work.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
First I will try I guess with SerialPort methods. If some issue occurs, then I think I will revert to that PInvoke approach in that thread
|
|
|
|
|
Hi is there anyone who can give me a link where can i download working remote desktop view using c# together with the source code
PS: remote desktop viewer using local area network
|
|
|
|
|
That isn't what we are here for: we are not a Google search assistant, and we don't provide full systems on demand.
Start with Google, and see where you get.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Do google for it
|
|
|
|
|
Hi,
I am trying to send a *.xlsx file as an email attachment in #c for that we write the below code
Attachment item = new Attachment(fileName.xslx,MediaTypeNames.Application.Octet);
item.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
mail.Attachments.Add(item);
mail.IsBodyHtml =true;
mail.BodyEncoding =Encoding.UTF7;
mail.HeadersEncoding =Encoding.UTF7;
stmp.Send(mail);
By doing this in some machines we are able to send the mail successfully,but in some machines we are not able to send and also from those machines we are getting a mail with junk characters as body of the mail.
Please help us if anybody knows anything related to this(we are suspecting it might be machine settings problem,but we dont know what settings we need to change)
|
|
|
|
|
Don't create a duplicate thread - update your first one
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Why are you using UTF7? That's probably the issue. You should be using UTF8.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi
We tried with UTF8 also that is also not working,but strangely as mentioned above even with UTF7 it is working on some machines
|
|
|
|
|
I have this C++ code for setting timeouts on serial port
COMMTIMEOUTS *timeouts = new COMMTIMEOUTS ;
memset(timeouts, 0, sizeof(COMMTIMEOUTS)) ;
timeouts->ReadIntervalTimeout = ReadIntervalTimeout ;
timeouts->ReadTotalTimeoutMultiplier = 5 ;
timeouts->ReadTotalTimeoutConstant = readTimeOut ; timeouts->WriteTotalTimeoutConstant = 0 ; timeouts->WriteTotalTimeoutMultiplier = 2*BaudRate/8 ;
const bool ret = SetCommTimeouts(*hDev, timeouts) != FALSE ;
delete timeouts ;
m_currentTimeOut = readTimeOut ;
I need to rewrite this in C#. For SerialPort class I found these properties:
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;
Are they equivalent? It seems there are more parameters in play in the C++ code. How can I approach this? Or maybe other parameters are not needed? What is the best way to transform that C++ code to C#?
|
|
|
|
|
|
Not really, see on C++ there are more parameters about time out whereas on C# there is only 2. So it means I can't do exact mapping...?
|
|
|
|
|
user20044 wrote: whereas on C# there is only 2. Yes exactly, C# is a much easier language than C++ and is a high level language; whereas, C++ is a low-level language. C++ will likely always give equal to or greater control to the developer.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
user20044 wrote: and I need to rewrite this to C#. Yes, I understand that. And I'm telling you that C# does not expose all the same features that you can access in C++. So, either do it in C++ with the code you have or write it in C# and let the OS handle some of those properties for you that C++ does allow you to set.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
It all depends on what you are doing and what environment it is. If this is a windows application also written in C#, then yes, use the C#.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Original application is written in C++ (see for more code on the other question I linked above), and I need to rewrite to C#
|
|
|
|
|
Hi
I am new to C#, I wrote a code to prepare a *.xlsx file now I need to attach that file as an email attachment and send, but by doing that Thae mail body contains some junk data and also it is not giving any exceptions to catch.
Please help
|
|
|
|
|
Help with what? You haven't shown us the code that builds the email message so it's pretty much impossible to tell you what you did wrong.
|
|
|
|
|
|
Message Closed
modified 29-Sep-15 9:30am.
|
|
|
|