2

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.

user3931552
  • 21
  • 1
  • 2
  • 1
    You could try setting the project type to multibyte rather than unicode, but I do not know if that is a valid option when using MFC. – Retired Ninja Aug 12 '14 at 01:48
  • The project might be set to unicode character set. This would cause your program to link to the wide version of mciSendStringW rather than the multibyte version mciSendStringA. – Beed Aug 12 '14 at 01:49
  • Setting to multibyte in project properties, general, character set fixed my problem. Thank you very much! – user3931552 Aug 14 '14 at 17:14

2 Answers2

3

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.

ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15
0

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