If you already know how to make api calls...
Have this.

There should be a file 'Avifil32.dll' in your windows
system directory. All avi creation /editing programs make
use of this.

But I can't tell you how to do this or that.
May be you should search web on how to use the dll.