However I can definitely see your point here but since the functions are all internal to shell32 at this point and can accept any parameters you may like, I would consider it a cleaner solution to allocate a structure on the stack which contains such helper variables together with the pointer to the user supplied BROWSEINFOA structure and pass its pointer as custom long variable to the dialog procedure instead of lpbi only.
There is something I don't understand though.
According to msdn:
INT_PTR DialogBoxParam(
HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam );
dwInitParam [in] Specifies the value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG message.
So yes, I could put it all in a structure on the stack and then pass it to the dlgproc, but it will only arrive there on WM_INITDIALOG. However, I will also need the structure when the other messages come in. So where do I save it then, if I cannot put it in a global var? Am I missing something?
Robert