Re: Dumb buffer question.

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu