I can't compile your code in Delphi and I hate pointer arithmetic with a passion, but I wanted to ask why you changed all the integer declarations to Longword?