Hi
Unfortunately there is (to my knowledge) currently no API for programmatically modifying mex files.
Nevertheless, I know that with the coming Release 2014, such an API is going to be available, as part of the new MIKE SDK. So if you can wait until end of this year or beginning of next year, then you have it.
Best regards
Jesper