This example uses WinQueryLboxItemText to copy all of the list box items into a buffer.
#define INCL_WINLISTBOXES #define INCL_WINWINDOWMGR #include <OS2.H> LONG cWindows; char *szTemp; HWND hwndLB; SHORT maxchar, index = 0; cWindows = WinQueryLboxCount(hwndLB); /* allocate a buffer for cWindows items. */ DosAllocMem((PPVOID)&szTemp, (ULONG)cWindows*256*sizeof(char), PAG_READ | PAG_WRITE | PAG_COMMIT); /* loop through all of the items; copying each */ /* one the buffer. */ while (index <= cWindows) { maxchar = WinQueryLboxItemTextLength(hwndLB,index); WinQueryLboxItemText(hwndLB, index++, szTemp, maxchar); (*szTemp)+=maxchar*sizeof(char); /* increment pointer by number */ /* of bytes copied. */ }