Thursday, August 03, 2006

How to create a LPTSTR,

Well yesterday i ran into the problem of making LPTSTR ,and i found that LPTSTR is an TCHAR * so you can allocate in TCHAR . another way we use it in MFC was to use CString then use the GetBuffer and ReleaseBuffer,some times it hapens that the function needs an LPTSTR .
I fixed the problem by making a smart pointer of type BYTE and then passed this class to that function were it allocates and gives me back .it converts the BYTE to LPTSTR using the reinterpret_cast(arg);

Note :-
DWORD :- unsigned Long
WORD :- unsigned Short also known as an ATOM .
TCHAR :- converts itself into the unicode or mbcs according to the hash define in the settings .
_T()- this is macro short form of TEXT().
_tcs :- the one used in front of the string functions which can be used both for the
unicode ,Multibyte etc ,it will convert itself into _mbcs** or simple strcpy according to the define in settings .
While setting this we neeed to give an entry point also in mfc its always the _winmainstart**.( project settings + link tab + output (from the drop down))
while debugging if you need to see the unicode string you need to go to
Tool+OPtions+Debug TAB and then check the display unicode string.

No comments: