I am building a .SM2 and .RM2 extractor/compiler for a game but I am having trouble with the code. I am not experienced in C++ at all and the code is source code given by the original creator. Even his original file that wasnt edited by me had errors but he still made the program. Can someone please help me with the errors?
Errors:
Error1: error C2664: 'CreateDirectoryW' : cannot convert parameter 1 from 'const char [25]' to 'LPCWSTR'
Error2: error C2664: 'CreateDirectoryW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'(X3)
Error4: error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'char [256]' to'LPCWSTR'
Error5: error C2440: 'initializing' : cannot convert from 'WCHAR [260]' to 'char*'
Here is my code that apparently have the errors:
CreateDirectory(".\\TESTFOLDER\\TESTFOLD2ER", NULL); (This is for Error 1)
CreateDirectory(string, NULL);
break; (This is for Error2)
if ((hdl = FindFirstFile(asteriskpath, &data)) == INVALID_HANDLE_VALUE)
return; (For Error3)
char* filename = data.cFileName;
char current_dir[256]; (For Error4)
Please help, Thanks, Cameron Sawaya
Method 1: set your project character setting to
Use Multi-Byte Character Set
:Method 2:
For Error 1/2/4:
You should convert
char[]
towchar_t[]
first before passing toCreateDirectory()
(For your Error 1, similar for other errors 2 and 4) as they are using different character encoding types. Tryswprintf
with the%hs
flag.Example:
For Error 5:
You can use the
wcstombs
function to convertwchar_t[]
tochar[]
, reference here.