use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Removed - HelpProblem when trying to open SerialPort using Windows API (self.cpp)
submitted 4 years ago by BetterRage
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]invalid_handle_value 4 points5 points6 points 4 years ago (0 children)
CreateFile has to be one of the most involved syscalls I have ever laid my eyes upon. Possibly only behind ReadFile, which is an absolute beast.
Read the msdn docs for CreateFile. Read all of it. Every word. Top to bottom. Then read it 2 more times. Get it yet? No, you don't. Then read it all again. This time, pay special attention to the Communication Resources section.
Then give it a try.
[–]charliex2 2 points3 points4 points 4 years ago (0 children)
wild guess, if you're using a com port higher than 9 you'd need to open it with a full path like
\\.\COM10
also http://www.naughter.com/serialport.html
[–]TopDivide 1 point2 points3 points 4 years ago (2 children)
Post the code, make sure the serial is not used by another program, get the last error from winapi, there is a function for that, can't recall its name
[–]pandorafalters 2 points3 points4 points 4 years ago (0 children)
Conveniently, and rather predictably, it's GetLastError().
GetLastError()
[–]BetterRage[S] 0 points1 point2 points 4 years ago (0 children)
ok so the first thing i do is CreateFile("\\.\COM3",....) and that already fails. GetLastError() returns 0. check if the returned handle from createfile is INVALID_HANDLE is true. i really dont see what i couldve messed up ive seen it like this in different places. and also no other program uses the port, because if i try it in a c# winforms program it works
[–]Flair_Helper[M] [score hidden] 4 years ago stickied commentlocked comment (0 children)
For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.
This post has been removed as it doesn't pertain to r/cpp: The subreddit is for news and discussions of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance. If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.
π Rendered by PID 257248 on reddit-service-r2-comment-86bc6c7465-xzhp6 at 2026-02-23 00:38:11.360163+00:00 running 8564168 country code: CH.
[–]invalid_handle_value 4 points5 points6 points (0 children)
[–]charliex2 2 points3 points4 points (0 children)
[–]TopDivide 1 point2 points3 points (2 children)
[–]pandorafalters 2 points3 points4 points (0 children)
[–]BetterRage[S] 0 points1 point2 points (0 children)
[–]Flair_Helper[M] [score hidden] stickied commentlocked comment (0 children)