As the title states I have a simple char that retrieves a full path name of a file I am looking for and I need to convert it to const wchar_t. How can I achieve this? Here is an example of the code:
int main()
{
char filename[] = "poc.png";
char fullFilename[MAX_PATH];
GetFullPathName(filename, MAX_PATH, fullFilename, nullptr);
const wchar_t *path = fullFilename;
}
As you can see I am trying to get the filename to convert but I couldn't find a way to do so. What would be the most simple solution to this?
Your code doesn't show any need to convert between
char
andwchar_t
. Most likely you don't actually need to convert the character types. If you want to use thewchar_t
-friendlyGetFullPathNameW
, then just usewchar_t
instead ofchar
.If you really do need to convert between
wchar_t
-based C-style strings andchar
-based C-style strings, then you can use the APIsMultiByteToWideChar
andWideCharToMultiByte
.