You need to allocate a buffer yourself:
WCHAR txtbuff[50];
GetDlgItemText(hwnd, IDC_EDIT1, txtbuff, 50);
GetDlgItemText(hwnd, IDC_EDIT1, txtbuff, sizeof(textbuff)/sizeof(textbuff[0]));
MessageBox(NULL, txtbuff, L"Error message", MB_OK);
LPWSTR - , , . , GetDlgItem.