15,978
社区成员
发帖
与我相关
我的任务
分享
HANDLE heap=HeapCreate(0,1024*1024,1024*1024);
if(heap==NULL)
return;
int bufSize=GetWindowTextLength(hEdit)*sizeof(TCHAR)+4);
TCHAR* buf=(TCHAR*)HeapAlloc(heap,HEAP_ZERO_MEMORY,bufSize);
if(buf==NULL)
{
...
return;
}
int r=GetWindowText(hEdit,buf,bufSize);//???这里返回空
TCHAR buf[2048];
GetWindowText(hEdit,buf,2048);//???这里返回有数据
void GetEditText(HWND hEdit)
{
int iLen = SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0) + 1;
if(IsWindowUnicode(hEdit))
{
WCHAR *chBuff = new WCHAR[iLen];
ZeroMemory(chBuff, sizeof(*chBuff)*iLen);
SendMessage(hEdit, WM_GETTEXT, iLen, (LPARAM)chBuff);
OutputDebugStringW(chBuff);
OutputDebugStringW(L"\r\n");
delete [] chBuff;
}
else
{
CHAR *chBuff = new CHAR [iLen];
ZeroMemory(chBuff, sizeof(*chBuff)*iLen);
SendMessage(hEdit, WM_GETTEXT, iLen, (LPARAM)chBuff);
OutputDebugStringA(chBuff);
OutputDebugStringA("\r\n");
delete [] chBuff;
}
}