Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
bufstring.cpp
Package: shell.rar [view]
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 1k
Category:
Windows Kernel
Development Platform:
Visual C++
- HRESULT CBufferedString::SetBSTR(BSTR bstr)
- {
- int len = lstrlenW(bstr) + 1;
- if (len < ARRAYSIZE(m_szTmpBuf)) {
- if (m_fFree) {
- LocalFree(m_pBuf);
- m_pBuf = m_szTmpBuf;
- m_fFree = FALSE;
- }
- } else {
- if (m_fFree) {
- LPTSTR psz = (LPTSTR)LocalReAlloc(m_pBuf, len * SIZEOF(TCHAR), LMEM_MOVEABLE | LMEM_ZEROINIT);
- if (psz) {
- m_pBuf = psz;
- }
- else {
- return E_OUTOFMEMORY;
- }
- } else {
- LPTSTR psz = (LPTSTR)LocalAlloc(LPTR, len * SIZEOF(TCHAR));
- if (psz) {
- m_pBuf = psz;
- m_fFree = TRUE;
- }
- else {
- return E_OUTOFMEMORY;
- }
- }
- }
- #ifdef UNICODE
- lstrcpy(m_pBuf, bstr);
- #else
- WideCharToMultiByte(CP_ACP, 0, bstr, -1, m_pBuf, len, NULL, NULL);
- #endif
- m_fSet = TRUE;
- return S_OK;
- }