CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Andrew Truckle Guest

    [RESOLVED] HGLOBAL

    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.


  2. #2
    Guest

    Re: HGLOBAL

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured