Reputation: 645
Currently I am attempting to convert a QString
to a LPCWSTR
that will be used in URLDownloadToFile()
. The following is a simple version of my current code:
QString url = "http://whatever_file...";
HRESULT hRez = URLDownloadToFile(NULL, (LPCWSTR)url.toLocal8Bit().constData(), TEXT("C:\\etc..."), 0, NULL);
The conversion was found working, in the post I found it in, with conversion of QString
to LPCWSTR
. I am rather new in the field of programming and I simply added a letter to that solution as URLDownloadToFile
require it. It return no error however the download fail.
What am I missing here?
Upvotes: 0
Views: 1947
Reputation: 1177
To get LPCWSTR from QString you can use QString::constData method, because QChar is 2 byte Unicode symbol, exactly as WCHAR (if wchar_t is 2 byte on target machine).
And I aware you from the using of "TEXT" macro in one line with "LPCWSTR". You should use "L" instead.
"TEXT" is created for using in pair with the "LPCTSTR" macro. You can read this about them.
Upvotes: 3