1. Dumb buffer question.

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

new topic     » topic index » view message » categorize

2. Re: Dumb buffer question.


new topic     » goto parent     » topic index » view message » categorize

3. Re: Dumb buffer question.


new topic     » goto parent     » topic index » view message » categorize

4. Re: Dumb buffer question.

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."

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu