首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

向DLL中的函数传入CString参数的有关问题

2012-01-10 
向DLL中的函数传入CString参数的问题!主程序代码如下:CStringabc( 11 )CStringbabcif(!m_hInstance)m

向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

热点排行