I'm trying to perform the type conversion as shown in the subject title. Below shows the working copy of my code relevant to this conversion so far:
Code:
LPCSTR lpszOutput = "c:\\PDFTron_before.pdf";
SHELLEXECUTEINFOW File;
File.cbSize = sizeof(SHELLEXECUTEINFOW);
File.hwnd = NULL;
File.lpVerb = L"open";
File.lpFile = lpszOutput;
If I try using the green highlighted code, I'm getting the following error message:
Code:
1>c:\pdftron_vprint\shellscript\shellscript.cpp(20) : error C2440: '=' : cannot convert from 'LPCSTR' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
If I try replacing the highlighted code with:
Code:
int byteWritten = MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED,
lpszOutput,
-1,
(LPWSTR) File.lpFile,
0);
I'm getting a runtime error saying that File was used without being initialized. Does it imply that I should be allocating memory to File.lpFile?