Re: How to convert CString to LPCWSTR
* :
How to convert CString to LPCWSTR
Neither CString nor LPCWSTR are part of standard C++. I.e. the question is off
topic in this group (see the FAQ for suggestions of more appropriate groups to
post in). However, regarding the code sample below:
In my code, the function need a parameter LPCWSTR
And I find this can work
///////////////////////////////////////////////////////////////////////////?//////////////////////////////////////////
CFileFind finder;
BOOL bWorking = finder.FindFile(_T("C:\\*.bmp"));
Three things wrong with the above statement:
1. You're using a 'BOOL' type instead of standard C++ 'bool'.
2. You're using a Hungarian prefix 'b', and the rest of the name is meaningless
and misleading: try to train yourself in choosing meaningful names (e.g. look
at others' code).
3. You're using Microsoft _T, which is only meaningful if you have to use the
MFC library in a DLL *and* support both Windows 9x and modern Windows, which
it's almost guaranteed is not your situation.
As a general observation, it seems that you're employing the
monkey-see-monkey-do approach to programming, just copying and modifying code
snippets you find without understanding any of it.
A better (in the sense of more productive) approach is to understand things.
Cheers & hth.,
- Alf