You can't use MCSTR here as ep.getcstring() is a non static c-string. Use ep . copyasstringref().