ctWithSite 是否支持IE的调用
四、添加接口函数
STDMETHODIMP CFun::Add(long n1, long n2, long *pVal) { *pVal = n1 + n2; return S_OK; } 这个太简单了,不再浪费“口条”。下面我们实现字符串连接的Cat()函数:
STDMETHODIMP CFun::Cat(BSTR s1, BSTR s2, BSTR *pVal) { int nLen1 = ::SysStringLen( s1 ); // s1 的字符长度 int nLen2 = ::SysStringLen( s2 ); // s2 的字符长度 *pVal = ::SysAllocStringLen( s1, nLen1 + nLen2 );// 构造新的 BSTR 同时把 s1 先保存进去 if( nLen2 ) { ::memcpy( *pVal + n |
|