Hi, I got a small situation that I just can't figure out
This is a win API, the name kinda says it all, and the first parameter is the name of the file and the type as you can see is LPCWSTR, now, in C everything works fine if you simply type in "d:\sdaf\gfasd.txt" or whichever file you want to access, all neat and fine, but in C++ I got in to a whole lota trouble when I did this, the compiler gives me an errorCode:hFile = CreateFile ((LPCWSTR) bla , // this parameter bothers me GENERIC_READ, // open for reading FILE_SHARE_READ,...
//Error 2 error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char ' to 'LPCWSTR'
And if I typecast it then I get a bug, cuz the function won't open the file, stating it does not exist.
Then another thing I saw was that an example I was looking used a TCHAR *argv
and took argv into the first parameter and everything worked fine, then when I tried to decleare TCHAR *mystring, I used the sprintf_s and again it can't find the file, and belive me on this one, it is there. + the same process when I tried with the LPCWSTR.
I know C++ is pretty tough with typecasting, but sheeshh
Any ideas, solutions would be great, thanks.
PS: anything unclear?? just say (cuz I'm lousy at explaining things)