In get_button_text, the returned handle must be freed by caller (-> memory leak if it forgots about it).
That could be solved using something like :
/* BEGIN */
/* in button.c */
inline static void get_button_text(HWND hwnd, WCHAR *out, INT max_len) { INT len = MIN(GetWindowTextLengthW( hwnd ), max_len); GetWindowTextW( hwnd, buffer, len + 1 ); }
/* everywhere needed */
#define MAX_BUTTON_TEXT_LEN 255 /* just as an example */ caller_func(HWND hwnd) { WCHAR button_text[MAX_BUTTON_TEXT_LEN]; /* can also be dynamicaly allocated of course */ get_button_text(hwnd, button_text, MAX_BUTTON_TEXT_LEN); /* do something with gathered string */ }
/* END */
So, why wouldn't I do it myself ? Because I'm getting lost in sources :). I only crawl wine code for only 48 hours now... So about 5 hours of effective crawling.
Vincent Pelletier