Why is VC++ 2005 beta2 telling me this and how do I solve it.

.\Test2.cpp(42) : error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


Please note that this problem does not exist in VC++ 6.0

The documentation of your compiler keeps the answers to many "secrets". Besides ALPHA and BETA releases of programs carry these names for the sole reason to say that they are still unfinished.

lpcWstr erm wide char type.
char* narrow char type.
There is no relationship between the two types whatsoever therefore static_cast<> cant do it. You must use reinterpret_cast<>. It is only portable and safe if you then use reinterpret_cast<> back to LPCWSTR before using it.

lpcWstr erm wide char type.
char* narrow char type.
There is no relationship between the two types whatsoever therefore static_cast<> cant do it. You must use reinterpret_cast<>. It is only portable and safe if you then use reinterpret_cast<> back to LPCWSTR before using it.

AM sorry but i cannot understand it, can u be more clear

who is "u"?
who is "i"?

Use real English in writing and you might understand what others write as well.

Post the code. It's likely the function expects 'CString' and you are passing it a char *.

Post the code. It's likely the function expects 'CString' and you are passing it a char *.

i use it lik that:

FindFirstFile("where.exe", blah blah);

Post the actual code.

look the problem is this simple. You are calling a function that expects a LPCWSTR but you are passing char*. So to fix either pass a LPCWSTR (long pointer to a constant WIDE string) i.e. a unicode string or use the correct function for char*.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.