I have made a small project using DirectX. It uses Direct Draw to blt frames from a bitmap based on the input keys. I just want you guys to check my source code and tell me if it is programmed in an optimized form or I can still make improvements.
One major improvement would be memory management. Every time I run the program my memory page size increases by about 42mb. How do I remove the memory allocated for my program

The compressed size of the bitmap even in GIF format was 163 kb, so I had to split the file in 2 attachments due to the limitations of this site.