Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
306 views
in Technique[技术] by (71.8m points)

c++ - cannot convert parameter 1 from 'char' to 'LPCWSTR'

I keep getting this error: cannot convert parameter 1 from 'char' to 'LPCWSTR'

int main(int argc, char argv[])    
{

   // open port for I/O
   HANDLE h = CreateFile(argv[1],GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);

   if(h == INVALID_HANDLE_VALUE) {
       PrintError("E012_Failed to open port");

can someone help?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Go to the Properties for your Project and under Configuration Properties/General, change the Character Set to "Not Set". This way, the compiler will not assume that you want Unicode characters, which are selected by default:

alt text


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...