Well, there are several possibilities to solve this.
One is to prepare an array which is big enough for most cases, for example to hold 100 screens and 1000 windows or something like that. If the limits are reached anyway, you can either inform the user that he is using too much windows or just omit the remaining ones.
The second possbility is to go through the lists twice: first count the number of screens and windows, then allocate the array (using malloc or AllocVec) and finally go through the lists again and fill the array.
And the third solution is to use pointered lists yourself. This is the most dynamic version but it might be quite difficult to access because you don't have an array but have to walk through your own lists, too.
Bye,
Thomas