1. Dumb buffer question.
- Posted by Euman <euman at bellsouth.net> May 18, 2001
- 360 views
If anyone has used DragQueryFile could you tell me if UINT cch set to 128 byte buffer will be enough to accept the directory and file names UINT DragQueryFile( HDROP hDrop, UINT iFile, LPTSTR lpszFile, UINT cch ); I thought this would be enough but was wondering....< Is there a way to dynamically increase/decrease the buffer? Euman
4. Re: Dumb buffer question.
- Posted by Derek Parnell <ddparnell at bigpond.com> May 18, 2001
- 386 views
You could try something like this... //-------------------- void DropHandler( HDROP hDrop ) { UINT FileCount; UINT FileIndex; UINT LargestName = 0; UINT FileSize; LPTSTR BufAddr; // Get then number of files names to process. FileCount = DragQueryFile( hDrop, 0xFFFFFFFF, 0, 0 ); // Find the size of the largest filename. for( FileIndex = 1; FileIndex <= FileCount; FileIndex++) { FileSize = DragQueryFile( hDrop, FileIndex, 0, 0 ); if (FileSize > LargestName) { LargestName = FileSize; } } // Allocate enough RAM for the largest name plus zero terminator. BufAddr = (LPTSTR)malloc(LargestName + 1); // Process each of the file names. for( FileIndex = 1; FileIndex <= FileCount; FileIndex++) { FileSize = DragQueryFile( hDrop, FileIndex, BufAddr, LargestName + 1 ); // Call a routine to handler the dropped file name. myfilefunc(BufAddr); } // Restore the RAM free(BufAddr); } //-------------------- ------ Derek Parnell Melbourne, Australia "To finish a job quickly, go slower."