Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Anybody tell me how to use IStream correctly?

Anybody tell me how to use IStream correctly?

Scheduled Pinned Locked Moved ATL / WTL / STL
comhelptutorialquestionannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    max_xiayi
    wrote on last edited by
    #1

    The following is my code which use a IStream interface to dispaly JPEG.But after about 24 hours, an Assert error happened at NO.622 line in atlbase.h ////////////////////////////////////////////////////////////////////////// IStream* pStream=NULL; HGLOBAL hMemory=0; BOOL bIsPicture ; hMemory = ::GlobalAlloc( GMEM_MOVEABLE, iBufferLength ); ASSERT( hMemory != NULL ); LPVOID pData = ::GlobalLock( hMemory ); ASSERT( pData != NULL ); ASSERT(iBufferLength>=0); memcpy(pData,buf,iBufferLength); ::GlobalUnlock(hMemory ); ::CreateStreamOnHGlobal(hMemory,TRUE,&pStream ); ASSERT( pStream != NULL ); //here is other code if(pStream) { pStream->Release(); } if(hMemory) { ::GlobalFree(hMemory); hMemory=NULL; } please contact: ctbpl_xiayi@yahoo.com.cn

    T F 2 Replies Last reply
    0
    • M max_xiayi

      The following is my code which use a IStream interface to dispaly JPEG.But after about 24 hours, an Assert error happened at NO.622 line in atlbase.h ////////////////////////////////////////////////////////////////////////// IStream* pStream=NULL; HGLOBAL hMemory=0; BOOL bIsPicture ; hMemory = ::GlobalAlloc( GMEM_MOVEABLE, iBufferLength ); ASSERT( hMemory != NULL ); LPVOID pData = ::GlobalLock( hMemory ); ASSERT( pData != NULL ); ASSERT(iBufferLength>=0); memcpy(pData,buf,iBufferLength); ::GlobalUnlock(hMemory ); ::CreateStreamOnHGlobal(hMemory,TRUE,&pStream ); ASSERT( pStream != NULL ); //here is other code if(pStream) { pStream->Release(); } if(hMemory) { ::GlobalFree(hMemory); hMemory=NULL; } please contact: ctbpl_xiayi@yahoo.com.cn

      T Offline
      T Offline
      Todd Smith
      wrote on last edited by
      #2

      No idea where line 622 is. So I would suggest reading about "Return Values" and making proper use of them. Todd Smith

      1 Reply Last reply
      0
      • M max_xiayi

        The following is my code which use a IStream interface to dispaly JPEG.But after about 24 hours, an Assert error happened at NO.622 line in atlbase.h ////////////////////////////////////////////////////////////////////////// IStream* pStream=NULL; HGLOBAL hMemory=0; BOOL bIsPicture ; hMemory = ::GlobalAlloc( GMEM_MOVEABLE, iBufferLength ); ASSERT( hMemory != NULL ); LPVOID pData = ::GlobalLock( hMemory ); ASSERT( pData != NULL ); ASSERT(iBufferLength>=0); memcpy(pData,buf,iBufferLength); ::GlobalUnlock(hMemory ); ::CreateStreamOnHGlobal(hMemory,TRUE,&pStream ); ASSERT( pStream != NULL ); //here is other code if(pStream) { pStream->Release(); } if(hMemory) { ::GlobalFree(hMemory); hMemory=NULL; } please contact: ctbpl_xiayi@yahoo.com.cn

        F Offline
        F Offline
        f64
        wrote on last edited by
        #3

        Hi there The line 622 in atlbase.h is the -> operator of the CComQIPtr< > class template, and I don't see you are using any instance of it in the code you posted, so I suggest you to open the "Call stack" (Alt + 7) when you get the assert, and follow you way up until you reach the line in your code which is calling the -> operator on an instance of CComQIPtr<>, and then take a look why that pointer is NULL. Regards, Fabian

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups