You can use std::vector as an alternative, something like:Code:#include <vector> std::string GetWndTxt(const HWND hwnd) { int length=GetWindowTextLength(hwnd)+1; std::vector<char> tmp(length, '\0'); GetWindowText(hwnd,&tmp[0],length); return &tmp[0]; }