Then I would debug the code by adding a message box to every API function (or to Err.LastDllError if the API requires GetLastError as its return status) to check its return.
When you find which on fails (and you will know it fails by looking at what each function should return via MSDN - Just google the API function and MSDN will usually be the first link) then you can take it one step further and see why, based on what kind of values are being passed in as the parameters.
If u cant understand why it is failing, then I guess post back here with the name of the API function that is failing for you, and I or someone else might propose some suggestions to try.