Here's how to load the first video stream of an AVI file. Ripped from Microsoft's own source code, except I've changed it.

PS don't bother trying to find the original, it's hidden in the labryinthe that is the DirectX SDK.

PPS There are now faster ways to load AVIs, I believe this method of loading AVIs is now deprecated.

#include <stdlib.h>

#include <time.h>
#include <stdio.h>
#include <windows.h>
#include <vfw.h>

PAVISTREAM    m_paviStream;    // The AVI stream
PGETFRAME     m_pgfFrame;      // Where in the stream to get the next frame
AVISTREAMINFO m_psiStreamInfo; // Info about the AVI stream

HRESULT Core_AVI_OneTimeSceneInit(char *fileName,long *awidth,long *aheight)
{
	HRESULT hr;
	
	AVIFileInit();
    
    if( FAILED( hr = AVIStreamOpenFromFile( &m_paviStream, fileName,
                                     streamtypeVIDEO, 0, OF_READ,
                                     NULL ) ) )
    {
        printf("Could not locate AVI file <%s>.\n",fileName);
		return E_FAIL;
    }

    if( NULL == ( m_pgfFrame = AVIStreamGetFrameOpen( m_paviStream,
       NULL ) ) ) {
        printf("Opening AVI Stream was unsuccessful\n");
    	return E_FAIL;
    }

    
	if( FAILED( hr = AVIStreamInfo( m_paviStream, &m_psiStreamInfo,
		sizeof(AVISTREAMINFO) ) ) ) {
	     
		printf("Stream information does not exist.\n");
    	return E_FAIL;
	}

	printf("Video %s successfully loaded.\n",fileName);
  
	AVIStreamStart(m_paviStream);
	AVIStreamBeginStreaming(m_paviStream,m_psiStreamInfo.dwStart+1
,m_psiStreamInfo.dwLength,20000);    


    BITMAPINFO* pbmi;
    
	if( FAILED( pbmi = (BITMAPINFO*)AVIStreamGetFrame
( m_pgfFrame, m_psiStreamInfo.dwStart + 1 ) ) ) {
       printf("Initial frame was not accessible.\n");
       return E_FAIL;
	}

    unsigned char* pSrc  =(unsigned char*) (WORD*)( sizeof(BITMAPINFO)
 + (BYTE*)pbmi );

	(*awidth)  =*((long*)(((BYTE*)pbmi)+4)  );
   (*aheight) =*((long*)(((BYTE*)pbmi)+8) );
    
	printf("Width:%li   Height:%li\n",(*awidth),(*aheight));

    if((*((WORD*)(((BYTE*)pbmi)+14))) !=16 &&    
      (*((WORD*)(((BYTE*)pbmi)+14))) !=24) {
      printf("Sorry, only videos captured in 16 bit and 24 bit are allowed.	\n");
      exit(0);
    }

	return S_OK;
}

DWORD oldFrame=200;
HRESULT Core_AVI_UpdateTexture(unsigned long Coreavi_width,
                               unsigned long 
Coreavi_height,long *finalDest,long awidth,long aheight)
{
    static FLOAT fAVIStartTime = ((FLOAT)clock())/CLOCKS_PER_SEC;

    // Use the clock to find which frame we should be drawing
    FLOAT fCurrTime     = ((FLOAT)clock())/CLOCKS_PER_SEC;
    FLOAT fElapsedTime  = fCurrTime-fAVIStartTime;
    FLOAT fAVITimeScale = ((FLOAT)m_psiStreamInfo.dwRate)
           / m_psiStreamInfo.dwScale;
    DWORD dwCurrFrame   = (DWORD)( fElapsedTime * fAVITimeScale );

    // If we exceed the AVI length, wrap to the start of the AVI
    if( dwCurrFrame >= m_psiStreamInfo.dwLength )
    {
        fAVIStartTime = ((FLOAT)clock())/CLOCKS_PER_SEC;
        dwCurrFrame   = m_psiStreamInfo.dwStart + 1;
    }

	BITMAPINFO* pbmi;
	if( FAILED( pbmi = (BITMAPINFO*)AVIStreamGetFrame(
      m_pgfFrame, dwCurrFrame) ) )
       return E_FAIL;
   

	if((*((WORD*)(((BYTE*)pbmi)+14))) ==16) {
        
		WORD* pSrc  =(WORD*)( sizeof(BITMAPINFO) + (BYTE*)pbmi );

		for(unsigned int j=0;j<Coreavi_height;j++) {

			unsigned long* step2=(unsigned long*)
            (&finalDest[(Coreavi_height-1)*awidth-j*awidth]);
            step2+=(awidth-Coreavi_width)/2;
			step2+=((aheight-Coreavi_height)/2)*awidth;

			for( unsigned long i= Coreavi_width; i >0; i-- ) {
        
	            WORD orig=*pSrc++;

				*((step2))
					=
               (((((orig&(31<<10))>>7)<<16)+
				   (((orig&((31<<5)))>>2)<<8)+
				   (((orig&31)<<3)<<0)&0xFEFEFEFE));
				step2++;
			}
		}
	} else { 

		unsigned char* pSrc  =(unsigned char*) (WORD*)( sizeof(BITMAPINFO)
         + (BYTE*)pbmi );

 for(unsigned int j=Coreavi_height;j>0;j--) {
			unsigned long* step2=(unsigned long*)(&finalDest[(j-1)*awidth]);
			     step2+=(awidth-Coreavi_width)/2;
			step2+=((aheight-Coreavi_height)/2)*awidth;

			for( unsigned long i= Coreavi_width>>2; i >0; i-- ) {
		        
				*step2=
					(((*step2)&0xFEFEFEFE)>>1)
					+((*(((unsigned long*)(pSrc-1)))
					&0xFEFEFEFE)>>1
					);
				step2++;

				*step2=
					(((*step2)&0xFEFEFEFE)>>1)
					+((*(((unsigned long*)(pSrc+2)))
					&0xFEFEFEFE)>>1
					);
				step2++;

				*step2=
					(((*step2)&0xFEFEFEFE)>>1)
					+((*(((unsigned long*)(pSrc+5)))
					&0xFEFEFEFE)>>1
					);
step2++;

				*step2=
					(((*step2)&0xFEFEFEFE)>>1)
					+((*(((unsigned long*)(pSrc+8)))
					&0xFEFEFEFE)>>1
					);
            step2++;
				pSrc+=12;
			}
		}
	}

   return S_OK;
}