Header Files

The header files for the AppExt project are listed in alphabetical order. This source code is intended only as a supplement to existing Microsoft documentation.

Note

THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. MICROSOFT CORPORATION SHALL NOT BE LIABLE FOR ANY TECHNICAL OR EDITORIAL ERRORS OR OMISSIONS CONTAINED HEREIN.

 

  • The code header file, About.h, that supports the Help About snap-in for the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //About.h
    
    #ifndef _SAMPABOUT_H_
    #define _SAMPABOUT_H_
    
    #include <tchar.h>
    #include <mmc.h>
    
    class CSnapinAbout : public ISnapinAbout
    {
    private:
        ULONG   m_cref;
        HBITMAP m_hSmallImage;
        HBITMAP m_hLargeImage;
        HBITMAP m_hSmallImageOpen;
        HICON   m_hAppIcon;
    
    public:
        CSnapinAbout();
        ~CSnapinAbout();
    
        ///////////////////////////////
        // Interface IUnknown
        ///////////////////////////////
        STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
        STDMETHODIMP_(ULONG) AddRef();
        STDMETHODIMP_(ULONG) Release();
    
        ///////////////////////////////
        // Interface ISnapinAbout
        ///////////////////////////////
        STDMETHODIMP GetSnapinDescription( 
            /* [out] */ LPOLESTR *lpDescription);
    
            STDMETHODIMP GetProvider( 
            /* [out] */ LPOLESTR *lpName);
    
            STDMETHODIMP GetSnapinVersion( 
            /* [out] */ LPOLESTR *lpVersion);
    
            STDMETHODIMP GetSnapinImage( 
            /* [out] */ HICON *hAppIcon);
    
            STDMETHODIMP GetStaticFolderImage( 
            /* [out] */ HBITMAP *hSmallImage,
            /* [out] */ HBITMAP *hSmallImageOpen,
            /* [out] */ HBITMAP *hLargeImage,
            /* [out] */ COLORREF *cMask);
    
            ///////////////////////////////
            // Private Interface 
            ///////////////////////////////
    private:
        HRESULT CSnapinAbout::AllocOleStr(
            LPOLESTR *lpDest, 
            _TCHAR *szBuffer);
    };
    
    #endif _SAMPABOUT_H_
    
  • The code header file, AppExt.h, that supports the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //AppExt.h
    
    #ifndef _CPropSheetExtension_H_
    #define _CPropSheetExtension_H_
    
    #include <tchar.h>
    #include <mmc.h>
    
    class CPropSheetExtension : public IExtendPropertySheet, public ISnapinHelp2
    {
    private:
        ULONG m_cref;
    
        // clipboard format
        static UINT s_cfDisplayName;
        static UINT s_cfSnapInCLSID;
        static UINT s_cfNodeType;
    
    public:
        CPropSheetExtension();
        ~CPropSheetExtension();
    
       ///////////////////////////////
       // the XML DOM
       ///////////////////////////////
       IXMLDOMDocument* m_pXmlDom;
    
       ///////////////////////////////
       // Interface IUnknown
       ///////////////////////////////
       STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
       STDMETHODIMP_(ULONG) AddRef();
       STDMETHODIMP_(ULONG) Release();
    
       ///////////////////////////////
       // Interface IExtendPropertySheet
       ///////////////////////////////
       virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE CreatePropertyPages( 
       /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
       /* [in] */ LONG_PTR handle,
       /* [in] */ LPDATAOBJECT lpIDataObject);
    
       virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryPagesFor( 
       /* [in] */ LPDATAOBJECT lpDataObject);
    
       ///////////////////////////////
       // Interface ISnapinHelp
       ///////////////////////////////
       virtual HRESULT STDMETHODCALLTYPE GetHelpTopic( 
          __in LPOLESTR* pszwCompiledHelpFile );
    
       ///////////////////////////////
       // Interface ISnapinHelp2
       ///////////////////////////////
       virtual HRESULT STDMETHODCALLTYPE GetLinkedTopics( 
          __in LPOLESTR* pszwCompiledHelpFiles );
    
    private:
        LONG_PTR m_ppHandle;
    
        static INT_PTR CALLBACK DialogProc(HWND hwndDlg,  // handle to dialog box
            UINT uMsg,     // message
            WPARAM wParam, // first message parameter
            LPARAM lParam  // second message parameter
            );
    
    
        ///////////////////////////////
        // Private IDataObject support bits
        ///////////////////////////////
        HRESULT ExtractData( IDataObject* piDataObject,
            CLIPFORMAT   cfClipFormat,
            __in_bcount(cbData) BYTE*        pbData,
            __in DWORD        cbData )
        {
            HRESULT hr = S_OK;
    
            FORMATETC formatetc = {cfClipFormat, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
            STGMEDIUM stgmedium = {TYMED_HGLOBAL, NULL};
    
            stgmedium.hGlobal = ::GlobalAlloc(GPTR, cbData);
            do // false loop
            {
                if (NULL == stgmedium.hGlobal)
                {
                    hr = E_OUTOFMEMORY;
                    break;
                }
                hr = piDataObject->GetDataHere( &amp;formatetc, &amp;stgmedium );
                if ( FAILED(hr) )
                {
                    break;
                }
    
                BYTE* pbNewData = reinterpret_cast<BYTE*>(stgmedium.hGlobal);
                if (NULL == pbNewData)
                {
                    hr = E_UNEXPECTED;
                    break;
                }
                ::memcpy( pbData, pbNewData, cbData );
            } while (FALSE); // false loop
    
            if (NULL != stgmedium.hGlobal)
            {
                ::GlobalFree(stgmedium.hGlobal);
            }
            return hr;
        } // ExtractData()
    
        HRESULT ExtractString( IDataObject *piDataObject,
            CLIPFORMAT   cfClipFormat,
            __in_ecount(cchMaxLength) _TCHAR       *pstr,
            __in DWORD        cchMaxLength)
        {
            return ExtractData( piDataObject, cfClipFormat, (PBYTE)pstr, cchMaxLength );
        }
    
        HRESULT ExtractSnapInCLSID( IDataObject* piDataObject, CLSID* pclsidSnapin )
        {
            return ExtractData( piDataObject, (CLIPFORMAT) s_cfSnapInCLSID, (PBYTE)pclsidSnapin, sizeof(CLSID) );
        }
    
        HRESULT ExtractObjectTypeGUID( IDataObject* piDataObject, GUID* pguidObjectType )
        {
            return ExtractData( piDataObject, (CLIPFORMAT) s_cfNodeType, (PBYTE)pguidObjectType, sizeof(GUID) );
        }
    };
    
    #endif _CPropSheetExtension_H_
    
  • The code header file, BaseSnap.h, that provides the operating system definition support for the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //BaseSnap.h
    
    #ifndef _BASESNAP_H_
    #define _BASESNAP_H_
    
    // Modify the following defines if you have to target a platform prior to the ones specified below.
    // Refer to MSDN for the latest info on corresponding values for different platforms.
    #ifndef WINVER
    #define WINVER 0x0501 // Change this to the appropriate value for the version of Windows you need to target.
    #endif
    
    #ifndef _WIN32_WINNT
    #define _WIN32_WINNT 0x0501 // Change this to the appropriate value for the version of Windows you need to target.
    #endif
    
    #ifndef _WIN32_WINDOWS
    #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value for the version of Windows you need to target.
    #endif
    
    #ifndef _WIN32_IE
    #define _WIN32_IE 0x0501 // Change this to the appropriate value for the version of Internet Explorer you need to target.
    #endif
    
    
    STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj);
    STDAPI DllCanUnloadNow(void);
    
    ULONG g_uObjects = 0;
    ULONG g_uSrvLock = 0;
    
    class CClassFactory : public IClassFactory
    {
    private:
        ULONG m_cref;
    
    public:
        enum FACTORY_TYPE {CONTEXTEXTENSION = 0, ABOUT = 1};
    
        CClassFactory(FACTORY_TYPE factoryType);
        ~CClassFactory();
    
        STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
        STDMETHODIMP_(ULONG) AddRef();
        STDMETHODIMP_(ULONG) Release();
    
        STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *);
        STDMETHODIMP LockServer(BOOL);
    
    private:
        FACTORY_TYPE m_factoryType;
    };
    
    #endif _BASESNAP_H_
    
  • The code header file, Extend.h, that provides the node definition support for the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //Extend.h
    
    #ifndef _EXTEND_H
    #define _EXTEND_H
    
    struct EXTENSION_NODE
    {
        GUID   GUID;
        _TCHAR szDescription[256];
    };
    
    enum EXTENSION_TYPE
    {
        NameSpaceExtension,
            ContextMenuExtension, 
            ToolBarExtension,
            PropertySheetExtension,
            TaskExtension,
            DynamicExtension,
            DummyExtension
    };
    
    struct EXTENDER_NODE
    {
        EXTENSION_TYPE eType;
        GUID           guidNode;
        GUID           guidExtension;
        _TCHAR         szDescription[256];
    };
    
    #endif // _EXTEND_H
    
  • The code header file, Globals.h, that provides the global helper definitions for the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //Globals.h
    
    #ifndef _MMC_GLOBALS_H
    #define _MMC_GLOBALS_H
    
    #define STRSAFE_NO_DEPRECATE
    
    #include <tchar.h>
    #include <strsafe.h>
    
    #ifndef STRINGS_ONLY
            #define IDM_BUTTON1    0x100
            #define IDM_BUTTON2    0x101
    
            extern HINSTANCE g_hinst;
            extern ULONG g_uObjects;
    
            #define OBJECT_CREATED InterlockedIncrement((long *)&amp;g_uObjects);
            #define OBJECT_DESTROYED InterlockedDecrement((long *)&amp;g_uObjects);
    
    #endif
    
    //=--------------------------------------------------------------------------=
    // allocates a temporary buffer that will disappear when it goes out of scope
    // NOTE: be careful of that -- make sure you use the string in the same or
    // nested scope in which you created this buffer. people should not use this
    // class directly.  use the macro(s) below.
    //
    class TempBuffer {
      public:
        TempBuffer(ULONG cBytes) {
            m_size = 0;
            m_pBuf = (cBytes <= 120) ? &amp;m_szTmpBuf : HeapAlloc(GetProcessHeap(), 0, cBytes);
            m_fHeapAlloc = (cBytes > 120);
            if (m_pBuf) 
            {
                m_size = m_fHeapAlloc ? cBytes : ARRAYSIZE(m_szTmpBuf);
            }
        }
        ~TempBuffer() {
            if (m_pBuf &amp;&amp; m_fHeapAlloc) HeapFree(GetProcessHeap(), 0, m_pBuf);
        }
        void *GetBuffer() {
            return m_pBuf;
        }
    
        size_t GetBufferSize()
        {
            return m_size;
        }
      private:
        void *m_pBuf;
        // we'll use this temp buffer for small cases.
        //
        char  m_szTmpBuf[120];
        unsigned m_fHeapAlloc:1;
        size_t m_size;
    };
    
    //=--------------------------------------------------------------------------=
    // string helpers.
    //
    // given a _TCHAR, copy it into a wide buffer.
    // be careful about scoping when using this macro!
    //
    // how to use the below two macros:
    //
    //  ...
    //  LPTSTR pszT;
    //  pszT = MyGetTStringRoutine();
    //  MAKE_WIDEPTR_FROMSTR(pwsz, pszT);
    //  MyUseWideStringRoutine(pwsz);
    //  ...
    #ifdef UNICODE
    #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
        long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
        TempBuffer __TempBuffer##ptrname(__l##ptrname); \
        StringCchCopyW((LPWSTR)__TempBuffer##ptrname.GetBuffer(), __TempBuffer##ptrname.GetBufferSize(), tstr); \
        LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
    #else // ANSI
    #define MAKE_WIDEPTR_FROMTSTR(ptrname, tstr) \
        long __cch##ptrname = (lstrlenA(tstr) + 1);\
        long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
        TempBuffer __TempBuffer##ptrname(__l##ptrname); \
        MultiByteToWideChar(CP_ACP, 0, tstr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __cch##ptrname); \
        LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
    #endif
    
    #ifdef UNICODE
    #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
        long __l##ptrname = (lstrlenW(tstr) + 1) * sizeof(WCHAR); \
        LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
        StringCchCopyW((LPWSTR)ptrname, __l##ptrname, tstr)
    #else // ANSI
    #define MAKE_WIDEPTR_FROMTSTR_ALLOC(ptrname, tstr) \
        long __cch##ptrname = (lstrlenA(tstr) + 1);\
        long __l##ptrname = (lstrlenA(tstr) + 1) * sizeof(WCHAR); \
        LPWSTR ptrname = (LPWSTR)CoTaskMemAlloc(__l##ptrname); \
        MultiByteToWideChar(CP_ACP, 0, tstr, -1, ptrname, __cch##ptrname)
    #endif
    
    //
    // similarily for MAKE_TSTRPTR_FROMWIDE.  note that the first param does not
    // have to be declared, and no clean up must be done.
    //
    // * 2 for DBCS handling in below length computation
    //
    #ifdef UNICODE
    #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
        long __l##ptrname = (long)(wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
        TempBuffer __TempBuffer##ptrname(__l##ptrname); \
        StringCchCopyW((LPTSTR)__TempBuffer##ptrname.GetBuffer(), __TempBuffer##ptrname.GetBufferSize(), widestr); \
        LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
    #else // ANSI
    #define MAKE_TSTRPTR_FROMWIDE(ptrname, widestr) \
        long __l##ptrname = (long)(wcslen(widestr) + 1) * 2 * sizeof(TCHAR); \
        TempBuffer __TempBuffer##ptrname(__l##ptrname); \
        WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
        LPTSTR ptrname = (LPTSTR)__TempBuffer##ptrname.GetBuffer()
    #endif
    
    #endif // _MMC_GLOBALS_H
    
  • The code header file, Guids.h, that provides the GUID definition support for the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //Guids.h
    
    // TODO: generate a GUID for use as this plugin's "Extension ID" ("extid"): 
    //       place it here and in registry.cpp, line 112:
    const WCHAR g_szwExtId[] = L"{5F6A652F-1FA2-4A5C-B4DB-48D5D8095F47}";
    
    // TODO: generate a GUID for this plugin, 
    //       place it here and in registry.cpp, lines 46 and 115:
    
    // {A2E38A7B-D9B2-4DFC-8569-1F5383061590}
    DEFINE_GUID( CLSID_CPropSheetExtension, 
       0xA2E38A7B, 0xD9B2, 0x4DFC, 0x85, 0x69, 0x1F, 0x53, 0x83, 0x06, 0x15, 0x90 );
    
    
    // TODO: generate a GUID for snapin about interface, 
    
    // {E8072002-F374-471e-98AC-93F24D36752C}
    DEFINE_GUID( CLSID_CSnapinAbout, 
       0xE8072002, 0xF374, 0x471E, 0x98, 0xAC, 0x93, 0xF2, 0x4D, 0x36, 0x75, 0x2C );
    
  • The code header file, LocalRes.h, that provides the resource definition support for the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //LocalRes.h
    
    #ifndef __LocalResource_H__
    #define __LocalResource_H__
    
    #define INDEX_NONE          -1
    #define INDEX_SPACEICON     0
    #define INDEX_LANDICON      1
    #define INDEX_SKYICON       2
    #define INDEX_PEOPLEICON    3
    #define INDEX_CLOSEDFOLDER  4
    #define INDEX_OPENFOLDER    5
    
    #define INDEX_SUN 6
    #define INDEX_SNOW 7
    #define INDEX_RAIN 8
    #define INDEX_CLOUD 9
    #define INDEX_WORLD 10
    #define INDEX_THUNDER 11
    
    
    #endif // __LocalResource_H__
    
  • The code header file, Registry.h, that provides the registry support for the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //Registry.h
    
    #ifndef __Registry_H__
    #define __Registry_H__
    
    #include <tchar.h>
    
    // This function will register a component in the Registry.
    // The component calls this function from its DllRegisterServer function.
    HRESULT RegisterServer(HMODULE hModule, 
                           const CLSID&amp; clsid, 
                           const _TCHAR* szFriendlyName) ;
    
    // This function will unregister a component.  Components
    // call this function from their DllUnregisterServer function.
    HRESULT UnregisterServer(const CLSID&amp; clsid) ;
    
    
    // This function will register a Snap-In component.  Components
    // call this function from their DllRegisterServer function.
    HRESULT RegisterSnapin(const CLSID&amp; clsid,         // Class ID
                           const _TCHAR* szNameString, // NameString
                           const CLSID&amp; clsidAbout);   // Class Id for About Class
    
    
    HRESULT UnregisterSnapin(const CLSID&amp; clsid);         // Class ID
    
    #endif // __Registry_H__
    
  • The code header file, Utility.h, that provides the MSXML utility functions written for the extension to the property pages of the Applications snap-in is listed below.

    Note

    Any comment in the following code example that starts with "TODO:" refers to an action that you must perform when modifying the code for a new extension to the property sheets for the Applications snap-in. Comments that do not start with "TODO:" describe an action that the subsequent code will perform.

     

    //Utility.h
    
    #pragma once
    
    #define STRING_MATCH 0
    #define CCF_AUTOPROF_XMLDOM L"CCF_AUTOPROF_XMLDOM"
    
    #include <windows.h>
    #include <msxml.h>
    #include <objsafe.h>
    #include <objbase.h>
    #include <string>
    #include <comutil.h>
    using namespace std;
    
    HRESULT GetAttribute( 
       IXMLDOMNode* pParent,
       LPCTSTR szName, 
       BSTR&amp; bstrValue );
    
    HRESULT SetAttribute( 
       IXMLDOMDocument* pDom,
       IXMLDOMNode* pParent, 
       LPCTSTR szName, 
       LPCTSTR szValue );
    
    HRESULT AddElement( 
       IXMLDOMDocument* pDom,
       IXMLDOMNode* pParent,
       LPCTSTR szName, 
       IXMLDOMNode** ppNew );
    
    HRESULT AllocOleStr( 
       __out LPOLESTR* lppDest,
       __in LPCWSTR szwBuffer );