CString里的LockBuffer 和 unLockBuffer的作用是什么啊?
来源:互联网 发布:美食甜品软件 编辑:程序博客网 时间:2024/05/17 23:48
LockBuffer() 与 UnlockBuffer()
顾名思议,这两个函数的作用就是对引用内存块进行加锁及解锁。但使用它有什么作用及执行过它后对CString串有什么实质上的影响。其实挺简单,看下面代码:
(1) CString str("test");
(2) str.LockBuffer();
(3) CString temp = str;
(4) str.UnlockBuffer();
(5) str.LockBuffer();
(6) str = "error";
(7) str.ReleaseBuffer();
执行完(3)后,与通常情况下不同,temp与str并不指向同一引用内存块。你可以在watch窗口用这个表达式(CStringData*)((CStringData*)(str.m_pchData)-1)看看。
其实在msdn中有说明:
While in a locked state, the string is protected in two ways:
No other string can get a reference to the data in the locked string, even if that string is assigned to the locked string.
The locked string will never reference another string, even if that other string is copied to the locked string.
顾名思议,这两个函数的作用就是对引用内存块进行加锁及解锁。但使用它有什么作用及执行过它后对CString串有什么实质上的影响。其实挺简单,看下面代码:
(1) CString str("test");
(2) str.LockBuffer();
(3) CString temp = str;
(4) str.UnlockBuffer();
(5) str.LockBuffer();
(6) str = "error";
(7) str.ReleaseBuffer();
执行完(3)后,与通常情况下不同,temp与str并不指向同一引用内存块。你可以在watch窗口用这个表达式(CStringData*)((CStringData*)(str.m_pchData)-1)看看。
其实在msdn中有说明:
While in a locked state, the string is protected in two ways:
No other string can get a reference to the data in the locked string, even if that string is assigned to the locked string.
The locked string will never reference another string, even if that other string is copied to the locked string.
0 0
- CString里的LockBuffer 和 unLockBuffer的作用是什么啊?
- 程序里wstring,string和CString的Buffer里到底存的是什么(菜鸟问题)
- Ajax里的onreadystatechange的作用是什么
- Ajax里的onreadystatechange的作用是什么
- Ajax里的onreadystatechange的作用是什么
- Ajax里的onreadystatechange的作用是什么
- Ajax里的onreadystatechange的作用是什么
- CString:Getbuffer和Releasebuffer的作用
- Python里的*args和**kwargs是什么?
- XmlWriteMode和XmlReadMode的作用是什么?
- XmlWriteMode和XmlReadMode的作用是什么?
- XmlWriteMode和XmlReadMode的作用是什么?
- 环境变量path和classpath的作用是什么?
- 环境变量path和classpath的作用是什么?
- 数据字典的内容和作用是什么?
- 环境变量path和classpath的作用是什么?
- 环境变量path和classpath的作用是什么?
- jsp的动作和作用分别是什么?
- ios 画图总结
- linux下安装包的问题(安装包在光盘上,rpm -qa技巧)
- 黑马程序员---Java学习笔记之io2
- 转载-关于CString的总结
- (个人理解+转载)ANSI/ASCII/UTF8/UNICODE/GB2312/UCS-2/UTF16-文本的编码格式
- CString里的LockBuffer 和 unLockBuffer的作用是什么啊?
- [MFC]CString与其他类型的转换
- 什么是C语言中的宽字符与多字节字符
- [MFC]CString与其他类型的转换
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
- Xcode 5 中引入 C++ 模板代码无法编译通过的问题解决
- android 对sqlite数据库的增删改查
- How to Install Oracle Java on Ubuntu Linux
- FWNX - 补码 反码 负数 在电脑中的存放规则- 边界值