SQL Server Extended Stored Procedures

Hi,

I'm trying to write an extended stored procedure for sql server 7 or
2000, I got the srv.h header and redefined all the tokens, types and
constants in Delphi

When I try this code

Exec @return= xp_dll @in, @out
print cast (@return As char(5))

I don't get any return messages from the server, the only thing i get
is @return = 1 which means return FAIL from the dll function even i
simplified the dll proc to only check te number of parameters and
return a message

IS there any way to do this in Delphi or I have to count on C++ for
the XP's

any help Will be apreciated