- DragQueryFile (hFilesInfo, wIndex, (LPTSTR) wxBuffer, 1000);
- files[wIndex] = wxBuffer;
+ // first get the needed buffer length (+1 for terminating NUL)
+ size_t len = ::DragQueryFile(hFilesInfo, wIndex, NULL, 0) + 1;
+
+ // and now get the file name
+ ::DragQueryFile(hFilesInfo, wIndex,
+ files[wIndex].GetWriteBuf(len), len);
+
+ files[wIndex].UngetWriteBuf();