user3931552
user3931552

Reputation: 31

C2664 error c++ Visual Studio

I am trying to modify an old MFC program. After opening the project in Visual Studio 2013 there are many errors of the type below.

In AviPlay.cpp

#include "stdafx.h"
#include "AviPlay.h"

#define OPEN_AVI_VIDEO "open avivideo"
BOOL initAVI()
{
    return mciSendString(OPEN_AVI_VIDEO, NULL, 0, NULL) == 0;
}

The error thrown is error C2664: 'MCIERROR mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND)' : cannot convert argument 1 from 'const char [14]' to 'LPCWSTR'

Should setting the compiler option for Strict to off, or some other compiler option, resolve this error? If not, I can modify the many lines of code manually. In that case, what might have changed in the last 15 years that would make code like this OK before but not OK now?

Thank you in advance.

Upvotes: 3

Views: 6187

Answers (2)

Madhusudan Samantray
Madhusudan Samantray

Reputation: 17

Also if you are creating a new project and facing this issue , then make the conformance mode to Default or No .

Upvotes: 1

ScottMcP-MVP
ScottMcP-MVP

Reputation: 10425

LPCWSTR tells you it is expecting a wchar_t string, not a char string. By default, all Windows APIs now accept wchar_t strings (unicode). You can change it back to char strings in the project properties, General page, Character Set. Setting it to 'Use Multibyte char set' will get it working as it used to.

Upvotes: 3

Related Questions