473,657 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error in opening serial port in Visual Studio 2005

1 New Member
Hi
i am working on serial port programming using CreateFile function in VC.
This function runs well in Visual Studio 6, while the same instruction fail to execute in VS2005. Can any one tell what will be the correct syntex or the possible cause of error.

hComm = CreateFile("COM 1:",GENERIC_REA D|GENERIC_WRITE ,0,0,OPEN_EXIST ING,0,0);

the above function runs fine in VS6 but it gives error no 2664: in VS2005.
telling that "cannot convert parameter1 from const char[6] to LPCWSTR".

Thanx
Jul 28 '09 #1
1 3102
Savage
1,764 Recognized Expert Top Contributor
By default VS2005 projects are set to use Unicode.Change that in project properties or call it like this:

hComm = CreateFile(_T(" COM1:"),GENERIC _READ|GENERIC_W RITE,0,0,OPEN_E XISTING,0,0);

The macro _T or TEXT maps string literals to Unicode or ASCII string depending on the project Unicode support.
Jul 28 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3122
by: Ken | last post by:
When running a program in the debugger, what would cause it to crash without any error messages? I get "The program has exited with code 0 (0x0)". The program is a MDI app with threading for several serial ports. It only crashes when data is being received on one or more of the serial ports. Could someone please give me some ideas about what would cause a program to terminate in this way? Thanks....
4
3376
by: Dave Cullen | last post by:
I need help using the serial port under VB.NET. I found a control called AxMSComm which I assume is the comm control, but there's no documentation in my MSDN help. Where can I find descriptions of the methods and properties of this control? And why doesn't MSDN have it? Thanks
1
13937
by: sranger | last post by:
When I try to use a System.IO.Ports.SerialPort object to read from a serial port, half of the time I have no problems. However, after I successfully read from the serial port, then close the connection, either when re-opening it (in the same instance or a new instance of my program) I get either an IOException "The Handle is Invalid" exception or an ArgumentException "The portName is invalid. Now, I get the port name by doing this: String...
1
2336
by: Nathan Sokalski | last post by:
Visual Studio 2005 unexpectedly stopped generating the *.designer.vb files for *.aspx and *.ascx files. After a few days of frustration trying to fix this, I noticed that it had the following Warning in the Error List tab at the bottom of the screen: Generation of designer file failed: The relative virtual path '?/' is not allowed here. C:\Inetpub\wwwroot\CAT_aspnet\worldnews.aspx 0 0 CAT_aspnet
0
3530
by: fischermx | last post by:
Environment: Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP.050727-7600) Microsoft .NET Framework Version 2.0.50727 Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack 1 (KB926601) Hotfix for Microsoft Visual Studio 2005 Professional Edition - ENU (KB933608) Windows XP, SP2.
3
4739
by: Nasif | last post by:
HELLO ALL I am new in serial port programming. I am currently doing a program that communicates to DSP board through COM1 port. But I am using Microsoft Visual Studio 2005. The language that I am using is C#. I am using the built in class SerialPort provided by Microsoft. When I send some bytes to the output buffer they always appear somewhat later at the input buffer... This is really frustrating.I know how to turn off the local echo...
2
7823
by: Nasif | last post by:
Currently I am writing a program which sends and receives messages through serial port to a device. I am using C# and Microsoft Visual studio 2005 for windows program. But my problem is when i try to write in serial port from my windows a Timeoutexception is thrown. I use SerialPort class in System.IO.Ports and for writing port i used write() function under the built in class SerialPort. But when i use hyperterminal , everything goes fine....
2
14894
by: yalbizu | last post by:
#include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; const int NO_OF_STUDENTS=20; struct studentType { string studentFName; string studentLName;
6
9812
by: uvbaz | last post by:
Hi, i'm trying to set the serial port.(XP SP2, Visual Studio 2005). I use the example code from MSDN "configuring a communications resource". CreateFile pass through, however GetCommState return 0.With GetLastError(), i get the error number 87, which means "ERROR_INVALID_PARAMETER The parameter is incorrect. " I'm sure the serial port works, because i can use another program to read/write through it.
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.