Error C2664 In Visual Studio
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta error c2664 cannot convert parameter Discuss the workings and policies of this site About Us Learn more error c2664 cannot convert parameter 1 from about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack error c2664 in c++ Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping error c2664 lpcwstr each other. Join them; it only takes a minute: Sign up C2664 error c++ Visual Studio up vote 0 down vote favorite 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"
Error C2664 Cannot Convert Argument
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. c++ visual-studio-2013 c2664 share|improve this question asked Aug 12 '14 at 1:44 user3931552 11 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 1: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
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta
Error C2664 Cannot Convert Parameter From Const Char To Lpcwstr
Discuss the workings and policies of this site About Us Learn more mfc error c2664 about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack error c2664 cannot convert argument 1 from Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, http://stackoverflow.com/questions/25254938/c2664-error-c-visual-studio helping each other. Join them; it only takes a minute: Sign up error C2664: cannot convert parameter 1 from 'X' to 'X' up vote 1 down vote favorite I have a C++/Win32/MFC project in Visual Studio 2008, and I'm getting a strange error message when I compile it. I've created a small project to demonstrate the problem, and http://stackoverflow.com/questions/14713648/error-c2664-cannot-convert-parameter-1-from-x-to-x the main code is #ifndef _MyObject_h #define _MyObject_h class MyObject { public: MyObject() { } }; #endif // _MyObject_h // --- END MyObject.h // --- BEGIN ObjectData.h #ifndef _ObjectData_h #define _ObjectData_h template
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of http://stackoverflow.com/questions/36333429/c-visual-studio-error-c2664 this site About Us Learn more about Stack Overflow the company Business Learn http://www.cplusplus.com/forum/beginner/18751/ more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up C++ error c2664 visual studio error C2664 up vote 0 down vote favorite When I use this code if (GetKeyNameText(Key << 16, NameBuffer, 127)) { KeyName = NameBuffer; GoodKeyName = true; } I get the following error C2664 'int GetKeyNameTextW(LONG,LPWSTR,int)': cannot convert argument 2 from 'char [128]' to 'LPWSTR' The NameBuffer says this: Error: argument of type "char*" is incompatible with parameter of type "LPWSTR" Any error c2664 cannot tips? c++ c2664 share|improve this question edited Mar 31 at 12:39 NathanOliver 41.4k125393 asked Mar 31 at 12:24 Hannumasa 1 msdn.microsoft.com/en-us/library/… –OldProgrammer Mar 31 at 12:27 where have you defined NameBuffer? –Usama Zafar Mar 31 at 12:30 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote You have UNICODE defined, which means all your functions and TCHAR and LPTSTR are defaulting to wide characters (wchar_t). That means you can't use a narrow-character string (using char) without special care. There is an easy solution, and that's to explicitly call the narrow-character version of the function: GetKeyNameTextA. Another solution is to stop using char and change to TCHAR and related types, and use the T macro for string literals. You might want to read more about UNICODE in the Windows API. share|improve this answer answered Mar 31 at 12:28 Joachim Pileborg 210k15141249 um, a LPWSTR is always a wchar_t* –NathanOliver Mar 31 at 12:30 1 @NathanOliver The UNICODE macro causes GetKeyNameText to be an alias (a macro really) for GetKeyNameTextW which explicitly uses LPWSTR. If you see the GetKeyName
be) I wondered if someone could help me with this file, the error massage I get when I compile the project is: error C2664: 'bokstav' : cannot convert parameter 1 from 'char *(__cdecl *)(char)' to 'char *' What is that mean? And how can I fix it. The file is suppose to convert Morse-code to Swedish text or English and contrary. The language in cout is in Swedish. I am a beginner in programming in C++, so please use a easy understanding language. If there is any questions about anything else just text me (e-mail or in this forum). / Puckosmucko, pleas help me. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include