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
bcw.cpp
Package: shell.rar [view]
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 3k
Category:
Windows Kernel
Development Platform:
Visual C++
- /****************************************************************************
- bcw.cpp
- Owner: Srinik
- Copyright (c) 1995 Microsoft Corporation
- This file contains code for BCW class which implements wrappers for IBindCtx
- and IRunningObjectTable. We use this object to trick the moniker binding
- code to create a new instance of the object (that the moniker is
- referring to) instead connecting to already running instance.
- ****************************************************************************/
- // #include "hlmain.h"
- #include "bcw.h"
- ASSERTDATA
- /****************************************************************************
- Implementation of BCW methods.
- ****************************************************************************/
- BCW::BCW(IBindCtx * pibc)
- {
- m_pibc = pibc;
- pibc->AddRef();
- m_cObjRef = 1;
- DllAddRef();
- }
- BCW::~BCW()
- {
- m_pibc->Release();
- DllRelease();
- }
- IBindCtx * BCW::Create(IBindCtx * pibc)
- {
- BCW * pbcw = new BCW(pibc);
- if (pbcw == NULL)
- return NULL;
- if (! pbcw->m_ROT.FInitROTPointer())
- {
- delete pbcw;
- return NULL;
- }
- return pbcw;
- }
- STDMETHODIMP BCW::QueryInterface(REFIID riid, void **ppvObj)
- {
- if (ppvObj == NULL)
- return E_INVALIDARG;
- if (riid == IID_IUnknown || riid == IID_IBindCtx)
- {
- *ppvObj = this;
- }
- else
- {
- *ppvObj = NULL;
- return E_NOINTERFACE;
- }
- ((IUnknown *) *ppvObj)->AddRef();
- return NOERROR;
- }
- STDMETHODIMP_(ULONG) BCW::AddRef(void)
- {
- return ++m_cObjRef;
- }
- STDMETHODIMP_(ULONG) BCW::Release(void)
- {
- /* Decrement refcount, destroy object if refcount goes to zero.
- Return the new refcount. */
- if (!(--m_cObjRef))
- {
- delete this;
- return 0;
- }
- return m_cObjRef;
- }
- /****************************************************************************
- Implementation of BCW_ROT methods.
- ****************************************************************************/
- /****************************************************************************
- BCW_ROT is the IRunningObjectTable imlementation of BCW_ROT.
- ****************************************************************************/
- BCW_ROT::BCW_ROT()
- {
- Debug(m_cRef = 0);
- m_piROT = NULL;
- }
- BCW_ROT::~BCW_ROT()
- {
- if (m_piROT)
- m_piROT->Release();
- }
- BOOL_PTR BCW_ROT::FInitROTPointer(void)
- {
- if (m_piROT == NULL)
- {
- if (GetRunningObjectTable(NULL/*reserved*/, &m_piROT) == NOERROR)
- m_piROT->AddRef();
- }
- return (BOOL_PTR) (m_piROT);
- }
- inline BCW * BCW_ROT::PBCW()
- {
- return BACK_POINTER(this, m_ROT, BCW);
- }
- STDMETHODIMP BCW_ROT::QueryInterface(REFIID riid, void **ppvObj)
- {
- if (riid == IID_IUnknown || riid == IID_IRunningObjectTable)
- {
- *ppvObj = this;
- }
- else
- {
- *ppvObj = NULL;
- return E_NOINTERFACE;
- }
- ((IUnknown *) *ppvObj)->AddRef();
- return NOERROR;
- }
- STDMETHODIMP_(ULONG) BCW_ROT::AddRef(void)
- {
- return PBCW()->AddRef();
- }
- STDMETHODIMP_(ULONG) BCW_ROT::Release(void)
- {
- return PBCW()->Release();
- }