Click here to Skip to main content
15,867,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I was assigned to write a simple serial port communication program running at Windows. The resources which I can find from network are either the whole sample program project or code pieces. I've got some trouble in using the resources:
1. The code projects are almost in Win32. Those are too old to be used in latest versions of Visual Studio; such as VC++ 2012, 2013, ...
2. The sample codes usual contains functions like CreateFile(), ClosePort(), OpenPort(), ... and data types like HANDLE, which usually causes compilation error. Which header files should I include?
3. When I open the code projects using VC++2013, all of them failed.

I get used to use VC#, not VC++. Could anyone tell me how to get the sample codes which I can build it immediately using VC++ 2010 or above?
Posted

1. Win32 (now WINAPI) are still there: Visual Studio 2013 still features 'Win32 Projects'.

2. You get compilation error if you don't properly include the header files, for instance the documentation of CreateFile[^] clearly states you have to include Windows.h in your project.

3. Create a fresh application and add the code you find in MSDN documentation (for instance: "Configuring a Communications Resource"[^]).
 
Share this answer
 
Comments
Stan Huang 23-Jul-14 10:35am    
Thanks. I created a console program successfully including code snippet. It was built successfully. I can't verified it right now and will do it tomorrow. I believe it works. It could be my first workable VC++ program at work.
CPallini 23-Jul-14 13:20pm    
You are welcome.
 
Share this answer
 
Comments
Stan Huang 23-Jul-14 10:35am    
Not yet, I will try it later. Thanks.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900