I know that in a DOS/Windows application, you can issue system commands from code using lines like:
system(\"pause\");
or
s
Well, lsmod does it by parsing the /proc/modules file. That would be my preferred method.
/proc/modules