make sure your calling convention is correct. It will most likely be cdecl if nothing else is specified. Looking at your code, it looks like you are using register convention on the Delphi side and that c lib will know nothing about this. It will crash.