Seriously, stop casting CStrings to const char*. Here's why you don't need to.

http://msdn.microsoft.com/en-us/libr...=vs.60%29.aspx

I know that's not the problem here, but it's an unnecessary habit you should get out of.