Click to See Complete Forum and Search --> : HGLOBAL


Andrew Truckle
May 5th, 1999, 02:28 AM
I have the following:


char *mybuf;
unsigned short numbytes;

numbytes=adBmpSizeFromFile(filename);

if (numbytes) {
mybuf=malloc(numbytes);
adExtractBmpFileToBuffer(filename ,mybuf,&numbytes);

}






How can I convert this buffer into a HGLOBAL?

I need to to this because the existing code requires a HGLOBAL to be passed and not a char *.

Thanks for your help.

May 12th, 1999, 06:07 PM
Hello,

normally you would reserve blocks of memory in Win32 like this:

HGLOBAL hGlob = GlobalAlloc( GMEM, dwSizeOfMemoryBlock )

if ( hGlob != NULL )
{
char* pMyBuffer = GlobalLock ( hGlob );

// when buffer is no longer needed, call:
GlobalFree ( hGlob );
}

Uli