I could take a stab at a straight translation to Pascal, as I'm sure you can, but it depends on a whole bunch of stuff which is clearly defined in other headers/includes... without them, it really would be a stab in the dark.

From what you've said in your mail, you may well be able to get better assistance from others.

Was there a particular part of that function that was causing you problems or was it the whole thing?