m_pRecordset->Open("SELECT * FROM users",_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
与
m_pRecordset->Open("Driver={SQLServer};Server=SERVER;Uid=1;Pwd=1;Database=Data",adOpenStatic,adLockOptimistic,adCmdText);相比。
还有把_variant_t((IDispatch*)m_pConnection,true)写成m_pRecordset.GetInterfacePtr()的,他们有什么不同呢?如果前者速度快,我就想使用前者,可是我对MSDN中下面的话不太理解,请高手帮我详细的解释一下:
_variant_t( IDispatch* pDispSrc, bool fAddRef = true )
Constructs a _variant_t object of type VT_DISPATCH from a COM interface pointer. If fAddRef is true, then AddRef is called on the supplied interface pointer to match the call to Release that will occur when the _variant_t object is destroyed. It is up to you to call Release on the supplied interface pointer. If fAddRef is false, this constructor takes ownership of the supplied interface pointer; do not call Release on the supplied interface pointer.
上面说到的释放问题,我附带问一下,智能指针是不是不需要Release,加上它只是一个好习惯而已?
与
m_pRecordset->Open("Driver={SQLServer};Server=SERVER;Uid=1;Pwd=1;Database=Data",adOpenStatic,adLockOptimistic,adCmdText);相比。
还有把_variant_t((IDispatch*)m_pConnection,true)写成m_pRecordset.GetInterfacePtr()的,他们有什么不同呢?如果前者速度快,我就想使用前者,可是我对MSDN中下面的话不太理解,请高手帮我详细的解释一下:
_variant_t( IDispatch* pDispSrc, bool fAddRef = true )
Constructs a _variant_t object of type VT_DISPATCH from a COM interface pointer. If fAddRef is true, then AddRef is called on the supplied interface pointer to match the call to Release that will occur when the _variant_t object is destroyed. It is up to you to call Release on the supplied interface pointer. If fAddRef is false, this constructor takes ownership of the supplied interface pointer; do not call Release on the supplied interface pointer.
上面说到的释放问题,我附带问一下,智能指针是不是不需要Release,加上它只是一个好习惯而已?
解决方案 »
- 如何去除在2011-08-12 8:1 :30中的“-”“:”
- 有谁知道中文字符 CStdioFile::WriteString失败的原因??
- 单文档应用程序内存泄露问题
- 多线程与定时器问题
- 请问各位大虾,如何实现图片中的功能?该用什么实现呢?列表框还是什么呢???
- 在单文档,基于FormVIew建立视图,在这种情况下如何在MainFrame中获取View的指针
- 多媒体文件?
- 请问如何将一个console程序改为MFC的exe?(在线等)
- 如何分析和读一个MFC程序?
- MFC输出文本的宽度控制问题
- VC++中如何创建一个文件夹,保证给分!!!!
- vc6代码在VC7中编译产生的问题,我猜是MS为了以后的64位系统才做的更改
翻译的很垃圾,还是等ing