Ok, here is my problem: I am trying to write a function to get the text of an edit box (not the dialog kind). I want to return a char*, but if I free the memory first, there is nothing to return. If I return first, the memory doesn't get freed. What can I do?
Code:char* getText() { int len = GetWindowTextLength(m_hParent); char* buf = (char*)GlobalAlloc(GPTR, len + 1); GetWindowText(m_hParent, buf, len + 1); GlobalFree((HANDLE)buf); return buf; }




Reply With Quote