向DLL中的函数传入CString参数的问题!
主程序代码如下:
CString abc( "11 ");
CString b = abc;
if (! m_hInstance)
m_hInstance = ::LoadLibrary(_T( "regdll.dll "));
long lRes=::GetLastError();
if (m_hInstance)
{
VERIFY(pFunction = (SQRTFUNC*)::GetProcAddress(m_hInstance, "ExecuteSubStepByName "));
lRes=::GetLastError();//
(*pFunction)(abc);
}
DLL中的函数是:
extern "C " _declspec(dllexport) bool ExecuteSubStepByName(const CString& sSubStepName)
我向DLL中的这个函数传入 "11 "字符串,但sSubStepName值为 "1 ",为什么会这样呢?
[解决办法]
CString最好只用在本进程里.
CString不包含字符串的长度,因此它在跨模块时是不安全的,用BSTR