MLGetArgCount()
int MLGetArgCount(MLINK link, long *n) finds the number of arguments to a function on link and stores the result in n.
See The Mathematica Book: Section 2.12.12.