Juan Lang escribió:
What do you think about this version?
Better, but still not correct:
- ret = DlgDirSelectExA( WIN_Handle32(hwnd), buffer, MAX_PATH, id );
- if (GetLastError() == 0) GetShortPathNameA(buffer, str, len);
You shouldn't check GetLastError() for whether DlgDirSelectExA succeeded. Rather, just check ret. You have the same problem in DlgDirSelectComboBoxEx16. --Juan
Sorry, but I have to object. According to the documentation in MSDN, DlgDirSelectExA returns nonzero when the current selection is a directory name, and zero when it is not. However, plain filenames do not qualify as directory names, so DlgDirSelectExA won't return nonzero on them either. I checked on wine's implementation just to be sure. So checking ret will not tell apart a case of failure from a case of a plain filename being returned. That is why I need to zero out the last error and check against it after return.