Mar 13, 2016 at 7:31pm Mar 13, 2016 at 7:31pm UTC
how can i convert from LPCTSTR to string?
i'm trying enum window properties, but i need print the properties names with cout, but the LPCTSTR type don't works with cout :(
Mar 14, 2016 at 10:04am Mar 14, 2016 at 10:04am UTC
What memory leak? Did you allocate memory for your string?
Mar 15, 2016 at 9:19pm Mar 15, 2016 at 9:19pm UTC
What is the value of lpszString ?
Mar 15, 2016 at 9:21pm Mar 15, 2016 at 9:21pm UTC
using a WriteConsole(), i get what i need, the property name. but i don't know what the string is by head. but seems that the windows ATOM's can get that results :(
Mar 19, 2016 at 5:56pm Mar 19, 2016 at 5:56pm UTC
finally i can convert them to a string:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
BOOL CALLBACK PropEnumProc(
_In_ HWND hwnd,
_In_ LPCTSTR lpszString,
_In_ HANDLE hData
)
{
ATOM atmText;
atmText=GlobalFindAtom(lpszString);
string strText;
#if defined(_UNICODE)
{
wchar_t szBuf[MAX_PATH] = { 0 };
GlobalGetAtomNameW(atmText, szBuf, _countof(szBuf));
GetAtomName(atmText,szBuf,_countof(szBuf));
wstring ws(txt);
strText(ws.begin(), ws.end());
}
#else
{
char szBuf[MAX_PATH] = { 0 };
GlobalGetAtomNameA(atmText, szBuf, _countof(szBuf));
strText=szBuf;
}
#endif
cout << strText << "\n" ;
return TRUE;
}
//use:
EnumProps(getwmpwindow,PropEnumProc);
getwmpwindow: it's a HWND object
thanks to all
Last edited on Mar 19, 2016 at 5:57pm Mar 19, 2016 at 5:57pm UTC