Don't do it unless you have excellent reasons to.
AVI is not a single format, it can contain as many different encodings as there are "fourcc" codes.
http://www.fourcc.org/codecs.php[
^]
And none of these format can be decoded from scratch. For instance, writing a simple MPEG decoder is a matter of several weeks of work.
You'd better find an open source solution.
Another less costly option is to use the old "Video for Windows" API. It allows you to open any AVI file for display or image extraction.
http://msdn.microsoft.com/en-us/library/dd757708(v=VS.85).aspx[
^].
Among others, you should have a look at the function
AVIStreamGetFrame
.