STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

comstl_rot_functions.h

Go to the documentation of this file.
00001 /* 
00002  * File:        comstl_rot_functions.h (originally MORotFns.h, ::SynesisCom)
00003  *
00004  * Purpose:     COM ROT (Running Object Table) functions.
00005  *
00006  * Created:     21st October 1998
00007  * Updated:     11th September 2004
00008  *
00009  * Home:        http://stlsoft.org/
00010  *
00011  * Copyright (c) 1998-2004, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * 
00039 
00040 
00044 
00045 #ifndef COMSTL_INCL_H_COMSTL_ROT_FUNCTIONS
00046 #define COMSTL_INCL_H_COMSTL_ROT_FUNCTIONS
00047 
00048 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00049 # define COMSTL_VER_H_COMSTL_ROT_FUNCTIONS_MAJOR    3
00050 # define COMSTL_VER_H_COMSTL_ROT_FUNCTIONS_MINOR    0
00051 # define COMSTL_VER_H_COMSTL_ROT_FUNCTIONS_REVISION 1
00052 # define COMSTL_VER_H_COMSTL_ROT_FUNCTIONS_EDIT     39
00053 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00054 
00055 /* 
00056  * Includes
00057  */
00058 
00059 #ifndef COMSTL_INCL_H_COMSTL
00060 # include "comstl.h"                // Include the COMSTL root header
00061 #endif /* !COMSTL_INCL_H_COMSTL */
00062 
00063 /* 
00064  * Namespace
00065  *
00066  * The COMSTL components are contained within the comstl namespace. This is
00067  * actually an alias for stlsoft::comstl_project,
00068  *
00069  * The definition matrix is as follows:
00070  *
00071  * _STLSOFT_NO_NAMESPACE    _COMSTL_NO_NAMESPACE    comstl definition
00072  * ---------------------    --------------------    -----------------
00073  *  not defined              not defined             = stlsoft::comstl_project
00074  *  not defined              defined                 not defined
00075  *  defined                  not defined             comstl
00076  *  defined                  defined                 not defined
00077  *
00078  */
00079 
00080 #ifndef _COMSTL_NO_NAMESPACE
00081 # if defined(_STLSOFT_NO_NAMESPACE) || \
00082      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00083 /* There is no stlsoft namespace, so must define ::comstl */
00084 namespace comstl
00085 {
00086 # else
00087 /* Define stlsoft::comstl_project */
00088 
00089 namespace stlsoft
00090 {
00091 
00092 namespace comstl_project
00093 {
00094 
00095 # endif /* _STLSOFT_NO_NAMESPACE */
00096 #endif /* !_COMSTL_NO_NAMESPACE */
00097 
00098 /* 
00099 
00104 
00105 /* 
00106  * Functions
00107  */
00108 
00118 inline HRESULT Rot_Register(DWORD       grfFlags,
00119                             LPUNKNOWN   punkObject,
00120                             LPMONIKER   pmkObjectName,
00121                             DWORD       *pdwRegister)
00122 {
00123     LPRUNNINGOBJECTTABLE    prot;
00124     HRESULT                 hr = ::GetRunningObjectTable(0, &prot);
00125 
00126     if(SUCCEEDED(hr))
00127     {
00128         hr = prot->Register(grfFlags, punkObject, pmkObjectName, pdwRegister);
00129 
00130         prot->Release();
00131     }
00132 
00133     return hr;
00134 }
00135 
00143 inline HRESULT Rot_Revoke(DWORD dwRegister)
00144 {
00145     LPRUNNINGOBJECTTABLE    prot;
00146     HRESULT                 hr = ::GetRunningObjectTable(0, &prot);
00147 
00148     if(SUCCEEDED(hr))
00149     {
00150         hr = prot->Revoke(dwRegister);
00151 
00152         prot->Release();
00153     }
00154 
00155     return hr;
00156 }
00157 
00166 inline HRESULT Rot_IsRunning(LPMONIKER pmkObjectName)
00167 {
00168     LPRUNNINGOBJECTTABLE    prot;
00169     HRESULT                 hr = ::GetRunningObjectTable(0, &prot);
00170 
00171     if(SUCCEEDED(hr))
00172     {
00173         hr = prot->IsRunning(pmkObjectName);
00174 
00175         prot->Release();
00176     }
00177 
00178     return hr;
00179 }
00180 
00191 inline HRESULT Rot_GetObject(   LPMONIKER   pmkObjectName,
00192                                 LPUNKNOWN   *ppunkObject)
00193 {
00194     LPRUNNINGOBJECTTABLE    prot;
00195     HRESULT                 hr = ::GetRunningObjectTable(0, &prot);
00196 
00197     if(SUCCEEDED(hr))
00198     {
00199         hr = prot->GetObject(pmkObjectName, ppunkObject);
00200 
00201         prot->Release();
00202     }
00203 
00204     return hr;
00205 }
00206 
00216 inline HRESULT Rot_NoteChangeTime(  DWORD       dwRegister,
00217                                     FILETIME    *lpfiletime)
00218 {
00219     LPRUNNINGOBJECTTABLE    prot;
00220     HRESULT                 hr = ::GetRunningObjectTable(0, &prot);
00221 
00222     if(SUCCEEDED(hr))
00223     {
00224         hr = prot->NoteChangeTime(dwRegister, lpfiletime);
00225 
00226         prot->Release();
00227     }
00228 
00229     return hr;
00230 }
00231 
00241 inline HRESULT Rot_GetTimeOfLastChange( LPMONIKER   pmkObjectName,
00242                                         FILETIME    *lpfiletime)
00243 {
00244     LPRUNNINGOBJECTTABLE    prot;
00245     HRESULT                 hr = ::GetRunningObjectTable(0, &prot);
00246 
00247     if(SUCCEEDED(hr))
00248     {
00249         hr = prot->GetTimeOfLastChange(pmkObjectName, lpfiletime);
00250 
00251         prot->Release();
00252     }
00253 
00254     return hr;
00255 }
00256 
00264 inline HRESULT Rot_EnumRunning(IEnumMoniker **ppenumMoniker)
00265 {
00266     LPRUNNINGOBJECTTABLE    prot;
00267     HRESULT                 hr = ::GetRunningObjectTable(0, &prot);
00268 
00269     if(SUCCEEDED(hr))
00270     {
00271         hr = prot->EnumRunning(ppenumMoniker);
00272 
00273         prot->Release();
00274     }
00275 
00276     return hr;
00277 }
00278 
00280 
00282 // Unit-testing
00283 
00284 #ifdef STLSOFT_UNITTEST
00285 
00286 namespace unittest
00287 {
00288     ss_bool_t test_comstl_rot_functions(unittest_reporter *r)
00289     {
00290         using stlsoft::unittest::unittest_initialiser;
00291 
00292         ss_bool_t               bSuccess    =   true;
00293 
00294         unittest_initialiser    init(r, "COMSTL", "rot_functions", __FILE__);
00295 
00296 #if 0
00297         if(<<TODO>>)
00298         {
00299             r->report("<<TODO>> failed ", __LINE__);
00300             bSuccess = false;
00301         }
00302 #endif /* 0 */
00303 
00304         return bSuccess;
00305     }
00306 
00307     unittest_registrar    unittest_comstl_rot_functions(test_comstl_rot_functions);
00308 
00309 } // namespace unittest
00310 
00311 #endif /* STLSOFT_UNITTEST */
00312 
00313 /* 
00314 
00315 #ifndef _COMSTL_NO_NAMESPACE
00316 # if defined(_STLSOFT_NO_NAMESPACE) || \
00317      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00318 } // namespace comstl
00319 # else
00320 } // namespace stlsoft::comstl_project
00321 } // namespace stlsoft
00322 # endif /* _STLSOFT_NO_NAMESPACE */
00323 #endif /* !_COMSTL_NO_NAMESPACE */
00324 
00325 /* 
00326 
00327 #endif /* !COMSTL_INCL_H_COMSTL_ROT_FUNCTIONS */
00328 
00329 /* 

STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004