Error C2664 Lpcwstr
Contents |
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 this site cannot convert from const char to lpctstr About Us Learn more about Stack Overflow the company Business Learn more about cannot convert from 'const char [14]' to 'lpcwstr' hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Const Wchar_t *' To 'lpcstr'
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 cannot convert parameter 1
How To Convert Const Char To Lpctstr In C++
from 'char' to 'LPCWSTR' up vote 21 down vote favorite 10 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? c++ windows createfile lpcwstr share|improve this question edited Jun 8 '15 at 22:40 Joseph Stine convert char* to lpcwstr 9551921 asked Oct 13 '10 at 14:45 sebastian 53361433 add a comment| 5 Answers 5 active oldest votes up vote 7 down vote accepted It should be int main(int argc, char* argv[]) And HANDLE h = CreateFileA(argv[1],GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL); share|improve this answer answered Oct 13 '10 at 14:51 ybungalobill 37.6k1074136 1 I don't thing using the ANSI version of CreateFile is the right way to go, next thing you know and he'll start changing all the function calls to use the ANSI version. –Nikola Smiljanić Oct 13 '10 at 15:00 1 @Nikola: Of course it's the wrong way! I just think that it's not appropriate to explain the difference between char, wchat_t, TCHAR and how to write correct unicode applications to an absolute beginner. –ybungalobill Oct 13 '10 at 15:04 add a comment| up vote 85 down vote 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: share|improve this answer answered Oct 13 '10 at 14:58 Michael Goldshteyn 37.4k1381139 add a comment| up vote 4 down vote This
here for a quick overview of the site Help Center Detailed answers to any questions you might have
Argument Of Type Const Char Is Incompatible With Lpcwstr
Meta Discuss the workings and policies of this site About Us lpcwstr c++ Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with lpwstr 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 http://stackoverflow.com/questions/3924926/cannot-convert-parameter-1-from-char-to-lpcwstr like you, helping each other. Join them; it only takes a minute: Sign up 'CreateDirectoryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' in OpenCV 2.4.5 and VS 2010 up vote 3 down vote favorite 1 I was trying the sample code bagofwords_classification.cpp from openCV 2.4.5 to Visual Studio 2010 (VC++ based). But I http://stackoverflow.com/questions/16555479/createdirectoryw-cannot-convert-parameter-1-from-const-char-to-lpcwstr found the error code : error C2664: 'CreateDirectoryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' Can you help me to give me the solution about that problem? Thanks. :) Update v1: static void makeDir( const string& dir ) { #if defined WIN32 || defined _WIN32 CreateDirectory( dir.c_str(), 0 ); #else mkdir( dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH ); #endif } static void makeUsedDirs( const string& rootPath ) { makeDir(rootPath + bowImageDescriptorsDir); makeDir(rootPath + svmsDir); makeDir(rootPath + plotsDir); } c++ opencv classification sample share|improve this question edited May 15 '13 at 1:56 asked May 15 '13 at 1:46 Dominikus Willy 6228 What exactly are you passing in? It's probably easy enough to make it a wide string from the start. –chris May 15 '13 at 1:48 I don't have anytthing to pass in. I just copy and paste that code bagofwords_classification.cpp and execute it. I don't know how to execute that code well. –Dominikus Willy May 15 '1
Sponsored Advertisement - Save Optional Authenticator Code Thread Tools error C2664: 'GetModuleHandleA': cannot convert parameter 1 from LPCWSTR http://www.unknowncheats.me/forum/d3d-tutorials-source/81118-error-c2664-getmodulehandlea-cannot-convert-parameter-1-lpcwstr-lpcstr.html to LPCSTR 12th November 2012, 10:13 PM #1 guyfromLV n00bie Join Date: Nov 2012 Posts: 20 Reputation: 10 Rep Power: 96 error C2664: 'GetModuleHandleA': cannot convert parameter 1 from LPCWSTR to LPCSTR I'm new to these forums and a newbie "hacker". I have some experience in C++ so I know how to solve const char basic problems. But this one I couldn't find a solution for. Tried to make my own hack menu using help from this http://www.unknowncheats.me/forum/d3...-and-d3d9.html After getting rid of most of the errors, this occured: Error 1 error C2664: 'GetModuleHandleA' : cannot convert parameter 1 from 'LPCWSTR' to 'LPCSTR' c:\users\drailer\documents\visual studio 2010\projects\win7hook\win7hook\framework.cpp 47 Error 2 error C2664: cannot convert from 'LoadLibraryA' : cannot convert parameter 1 from 'LPCWSTR' to 'LPCSTR' c:\users\drailer\documents\visual studio 2010\projects\win7hook\win7hook\framework.cpp 49 I tried changing GetModuleHandle to GetModuleHandleW and GetModuleHandleA but nothing worked, why's that? Any help would be appreciated. guyfromLV is offline guyfromLV View Public Profile Find More Posts by guyfromLV 12th November 2012, 10:36 PM #2 zoomgod Affiliate VIP Join Date: Aug 2007 Posts: 4,254 Reputation: 53180 Rep Power: 318 Recognitions: Former Staff Donation (8) Member of the Month (4) The "A" on the end of the function names implies multibyte string not unicode. You can remove the A or set project to use multibyte strings. Project default is unicode.. __________________ Links die, searching does not. (Fravia : searchlores.org) Quote: Originally Posted by stevemk14ebr you can't reason with stupid, now someone quote me and make it their sig zoomgod is offline zoomgod View Public Profile Find More Posts by zoomgod 12th November 2012, 10:38 PM #3 tim0n Master Contributor Join Date: Jun 2009 Posts: 1,314 R